.NET Framework Bookmark and Share   
 index > .NET Framework Networking and Communication > TCPIP Socket Connection Not working ?
 

TCPIP Socket Connection Not working ?

Hi to all,

I have 5Clientsin the network for eachClienthaving unique IP Address if i connect for eachClientand disconnect ,no problem.

my problem is if one of the Client not connected to network that time its show error connecting. the reminingClientsfailed to connection.

why its happning how can i reset socket connection when its fail.



void ButtonConnectOnClick(object obj, EventArgs ea)
{
foreach (DataRow row inClients.Tables[0].Rows)
{
Ip_Address = row["IP_Address"].ToString().ToUpper();
Port_No = (int)row["PortNo"];
conStatus.Text = "Connecting...";
Socket newsock = new Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Tcp);
IPEndPoint iep = new IPEndPoint(IPAddress.Parse(Ip_Address), Port_No);
newsock.BeginConnect(iep, new AsyncCallback(Connected), newsock);
}
}
void Connected(IAsyncResult iar)
{
client = (Socket)iar.AsyncState;
try
{
client.EndConnect(iar);
conStatus.Text = "Connected to: " + client.RemoteEndPoint.ToString();
client.BeginReceive(data, 0, size, SocketFlags.None,
new AsyncCallback(ReceiveData), client);
}
catch (SocketException)
{
conStatus.Text = "Error connecting";
}
}



ak
  • Moved byHarry ZhuMSFTTuesday, September 15, 2009 8:16 AMrelating to networking (From:Visual C# Language)
  •  
Iniyan
There is no relationship between multiple instances of sockets. I can't see how one Connect failing would affect any other, I would suspect that something must be different in how your program reacts after the failed connect.
http://www.alanjmcf.me.uk/ Please follow-up in the newsgroup. If I help, mark the question answered
Alan J. McFarlane
You can do a test with thefollowing test and reach the conclution.

1) Runn your Server component
2) Connect to the server with Telnet cline(Strt->Run->Telnet)
3)Open another instance of Telnet and connect to the same server socket
4) Check it is supported the multiple client , If yes check your clinet code

If Not connected read the Error message ,
I Think your server has to runn in multi threaded model to accept multiple client.

If this is usfull please mark as answer.

Regards,
Pramod

  • Proposed As Answer byPramod K V P Wednesday, September 16, 2009 6:44 AM
  •  
Pramod K V P

You can use google to search for other answers

Custom Search

More Threads

• Network Events to trigger actions in MSIE
• Overflow of data in data communication
• RAS Custom Scripting
• DOWNLOAD DOCUMENTS WITHOUT ASKING OPEN,SAVE DIALOG
• Backend application posting data to web server..
• Property Names referred by actual types in Dynamic Proxy Assembly (WCF)
• Stuck in Net.ConnectionGroup.Disassociate
• What Encoding To Fix my NetworkStream?
• TCP multi-client continous connection/data exchange
• Problem with sending UDP to Apple macs :(