Click here to Skip to main content
15,907,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
protected void Page_Load(object sender, EventArgs e)
        {
            byte[] data = new byte[1024];
            IPEndPoint ip = new IPEndPoint(IPAddress.Parse("192.168.0.109"), 10006);

            Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            string welcome = "Hello";
            data = Encoding.ASCII.GetBytes(welcome);
            server.SendTo(data, data.Length, SocketFlags.None, ip);

            IPEndPoint sender11 = new IPEndPoint(IPAddress.Parse("192.168.0.109"), 10009);
           // IPEndPoint sender11 = (IPEndPoint)ClientID
            EndPoint tmpRemote = (EndPoint)sender11;



            data = new byte[1024];
            int receivedDataLength = server.ReceiveFrom(data, ref tmpRemote);

            Response.Write(tmpRemote.ToString());
            Response.Write(Encoding.ASCII.GetString(data, 0, receivedDataLength));


how to solve this error

thanks in advance....
Posted
Updated 25-Oct-13 19:58pm
v2
Comments
Which line causes this exception and what is the scenario?
teja sai ravi 26-Oct-13 2:23am    
thanks for ur reply...error coming in
int receivedDataLength = server.ReceiveFrom(data, ref tmpRemote);
i want send and receive data from among different users connected in a LAN

1 solution

 
Share this answer
 
Comments
teja sai ravi 26-Oct-13 2:48am    
thanks for ur reply can u guide how to write code for message sending and receiving by udp's i new to this udp concepts please help me

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900