Server sending data then client recive and store in database table in windows service

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gadicherla
    New Member
    • Dec 2014
    • 3

    Server sending data then client recive and store in database table in windows service

    When server send data then client receive that data, in C# windows services where data receive continuously (Using IP Address and port number) . Please any one have idea help me code. Thanks one and all. This below code writing in console application . i want implement same logic in windows service side. but i want data receive continuously.

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net;
    using System.Net.Sockets;
    using System.Threading.Tasks;
    using System.IO;
    
    
    namespace ClientApplication
    {
       
    
    
        class Client
            {
            public static void Main()
            {
                IPEndPoint ip = new IPEndPoint(IPAddress.Parse("192.168.1.202"), 9000);
    
                Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
    
                try
                {
                    server.Connect(ip);
                }
                catch (SocketException e)
                {
                    Console.WriteLine("Unable to connect to server." +e);
                    return;
                }
    
                byte[] data = new byte[1024];
                int receivedDataLength = server.Receive(data);
                string stringData = Encoding.ASCII.GetString(data, 0, receivedDataLength);
                Console.WriteLine(stringData);
    
                server.Shutdown(SocketShutdown.Both);
                server.Close();
            }
    
            
    }
            }
    Above code write in console application, same logic implementing in windows service, but i want data receiving continuously
    Last edited by zmbd; Dec 22 '14, 01:42 PM. Reason: [z{merged related posts}{Please use the [CODE/] format around your posted script - see FAQ}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    Gadicherla:
    1) Not entirely sure of what you are asking; however, I think you can save the thread if you can reword the question.

    2) Please use the "Post Reply" button and not the "Report Abuse" button to post to threads.
    (^_^)
    Last edited by zmbd; Dec 22 '14, 01:46 PM.

    Comment

    • Gadicherla
      New Member
      • Dec 2014
      • 3

      #3
      Actually i want server send data client receive that continuously using in windows services . above code I'm writing in console application, i want same logic in windows services side.

      Comment

      • Gadicherla
        New Member
        • Dec 2014
        • 3

        #4
        How to call server.Receive( data) in windows services

        Comment

        Working...