Note that there are some explanatory texts on larger screens.

plurals
  1. POAsynchronous broadcast client in c#
    primarykey
    data
    text
    <p>any help/feedback would be appreciated. I'm developing a broadcast client receiver such that it receives data coming from the server. the client sends and receives data ASYNCHRONOUSLY. in other words i make use of methods such as socket.BeginReceiveFrom() and socket.BeginSendTo() however, i would like to somehow get the IP ADDRESS of the server, but when i use the method RemoteEndPoint() to get the IP address of the server i get errors. Part of the code is shown below.</p> <pre><code>private void Form1_Load(object sender, EventArgs e) { byteData = msgToSend.ToByte(); clientSocket.BeginSendTo(byteData, 0, byteData.Length, SocketFlags.None, epServer, new AsyncCallback(OnSend), null); byteData = new byte[1024]; //Start listening to the data asynchronously clientSocket.BeginReceiveFrom (byteData,0, byteData.Length,SocketFlags.None,ref epServer,new AsyncCallback(OnReceive),null); } private void OnReceive(IAsyncResult ar) { try { clientSocket.EndReceive(ar); byteData = new byte[1024]; // HERE MY CODE TO FIND THE IP ADDRESS OF THE SERVER IPEndPoint ip = (IPEndPoint)epServer.RemoteEndPoint; MessageBox.Show(Convert.ToString(ip.Address)); //Start listening to receive more data from the user clientSocket.BeginReceiveFrom(byteData, 0, byteData.Length, SocketFlags.None, ref epServer,new AsyncCallback(OnReceive), null); } catch (ObjectDisposedException) { } catch (Exception ex) { MessageBox.Show(ex.Message, "SGSclient: " + strName, MessageBoxButtons.OK, MessageBoxIcon.Error); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload