none
Asynchronous Server Socket RRS feed

  • Question

  • I am going to develop an application of Asynchronous Server Socket for handling many short connections. I haven't touched the area. There are two questions, please help me.

    1. Is it a console application or a windows service application?
    2. I am going to transmit a key(maybe a string or guid or public key etc) once the connection is made wait, how to implement it? I saw some online examples have byte[1024] etc, how to apply it to my case?

    Thanks.


    • Edited by ardmore Tuesday, June 10, 2014 3:17 PM add
    Tuesday, June 10, 2014 3:13 PM

Answers

  • Hello,

    >>1.Is it a console application or a windows service application?

    The console application is more usually used.

    >>2.I am going to transmit a key(maybe a string or guid or public key etc)  once the connection is made wait, how to implement it? I saw some online examples have byte[1024] etc, how to apply it to my case?

    I assume that the key is the context you want to transmit between server and client. For this, there is a method named Socket.BeginSendFile() which can transmit the file. I think you can use this method.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by ardmore Wednesday, June 11, 2014 3:50 PM
    Wednesday, June 11, 2014 3:05 AM
    Moderator

All replies

  • Hello,

    >>1.Is it a console application or a windows service application?

    The console application is more usually used.

    >>2.I am going to transmit a key(maybe a string or guid or public key etc)  once the connection is made wait, how to implement it? I saw some online examples have byte[1024] etc, how to apply it to my case?

    I assume that the key is the context you want to transmit between server and client. For this, there is a method named Socket.BeginSendFile() which can transmit the file. I think you can use this method.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by ardmore Wednesday, June 11, 2014 3:50 PM
    Wednesday, June 11, 2014 3:05 AM
    Moderator
  • Try one of the samples in the website below.  The socket class can be replaced with a TCP Class object since TCP inherits a socket class.

    http://msdn.microsoft.com/en-us/library/vstudio/w89fhyex(v=vs.100).aspx


    jdweng

    Wednesday, June 11, 2014 3:22 AM
  • There is a code
    // running the listener is "host.contoso.com".
            IPHostEntry ipHostInfo = Dns.Resolve(Dns.GetHostName());
            IPAddress ipAddress = ipHostInfo.AddressList[0];
            IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);
    How to past the web site
    "host.contoso.com".
    to the code?
    Wednesday, June 11, 2014 12:42 PM
  • You only can have a listener on the local PC.  You use the connect method for a remote PC.  Look at the webpage in my last posting.  The client and server code connect differently.  The server use a local endpoint using IPAny while the client connects to the serverIP address

    jdweng

    Wednesday, June 11, 2014 1:19 PM
  • 'System.Net.Dns.Resolve(string)' is obsolete: '"Resolve is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202"'
    Wednesday, June 11, 2014 1:47 PM
  • Why are you trying to use a local endpoint on a remote PC?  A listener (on server) always uses a local endpoint.  A client never uses a local end point, instead the client connects to the server.  Using a Local Enpoint with a remote PC should never be used.

    jdweng

    Wednesday, June 11, 2014 2:45 PM