Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
5.00/5 (3 votes)
See more: (untagged)
This is a difficult question and discussion was going on earlier, but as suggested by "SAKryukov" I am creating this as a New Post.

I know, many people will be benefited if a solution comes out, as many are already pondering over this problem. So, I thought CodeProjet would be the ideal place to brain jam :)

Question Begins here:

Imagine 2 users connected to Yahoo messenger or GTalk etc. Both the users are under the same LAN (i.e., same router), hence their Internet IP's are same but LAN IP's are different.

The question of Router configuration etc. will not arise at all. Because the persons under the same LAN are communicating with each other, without even bothering what their IP is and they are also communicating with another person in Montreal (i.e., out of the LAN).

The Socket Server is always running in the background, but the communication is entirely P2P.

The Problem: If a message sent from A in Montreal to B in Japan (C is also in Japan and in the same LAN as B). Now, the message from A destined for B will also be broadcast to C. Because the sockets are binded to an IP and Port. Since B & C have the same Internet IP, the sender message cannot resolve to the actual end point (i.e., the actual recipient of the message).
Posted
Comments
sufi2008123 2-Feb-11 7:23am    
i also face such problem.
part of my code:

//Connect RemoteEndPoint
//this Remote IP is 72.55.168.241

private void ConnectRemoteEndPoint()
{
TcpClient tcp_RemoteEndPoint=new TcpClient();
IPAddress ipAddr = IPAddress.Parse(192.168.1.3);
try
{
tcp_RemoteEndPoint.Connect(ipAddr, 2000);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

//Accept RemoteEndPoint
//This Remote IP 192.168.1.3

private void AcceptRemoteEndPoint()
{
TcpListener listener_tcp;
TcpClient tcp_Remote;
listener_tcp = new TcpListener(IPAddress.Parse(192.168.1.3), 2000);
listener_tcp.Start();
while (true)
{
tcp_Remote= listener_tcp.AcceptTcpClient();
}
)

Error comes from ConnectionRemoteEndPoint() function:

Error: A request to send or receive data was disallowed because the socket is not connected and ( when sending on datagram socket using sendto call)and no address was supplied.



My question link
http://www.codeproject.com/Questions/152601/Problem-to-connect-using-Socket.aspx

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