i got some error in c#

Posted by Kannan1986 under C# on 3/31/2010 | Views : 1104 | Status : [Member] | Replies : 5
Hi,

i got error in c# windows application.





private static void ListenForClients()
{
tcpListener.Start();

while (true)
{
try
{
// Blocks until a client has connected to the server
TcpClient client = tcpListener.AcceptTcpClient();

// Create a thread to handle communication
// with connected client
Thread clientThread = new Thread(new ParameterizedThreadStart(HandleClientComm));
clientThread.Start(client);
}
}
Error:
------

Only one usage of each socket address (protocol/network address/port) is normally permitted

Error Line:
-----------
private static void ListenForClients()
{
----->> tcpListener.Start();




Responses

Posted by: Vuyiswamb on: 3/31/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
When does this happen ? Do you run this code on a click of a button or what, if yes, if a user can click twice this i will cause this problem. for more info look at this
http://blogs.msdn.com/dgorti/archive/2005/09/18/470766.aspx

It's recommended to call Shutdown() before Disconnect to allow all data to be sent and received.This normally happens when a client tries to connect on a socket on which another connection has already been accepted

Thank you for posting at Dotnetfunda
[Administrator]

Kannan1986, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kannan1986 on: 3/31/2010 [Member] Starter

Up
0
Down
Yes... i placed this code inside button click..but it display the error message when i click first time...

Kannan1986, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 3/31/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
That means there is still an open connection. Did you read a link that i sent you?

Thank you for posting at Dotnetfunda
[Administrator]

Kannan1986, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Kannan1986 on: 3/31/2010 [Member] Starter

Up
0
Down
could you tell me...

how do send & Receive message from one system to another system through LAN using c# windows application...


please Very Urgent.....



Kannan1986, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 7/14/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
hey Sivakumari stop what you are doing. i will remove all the messages you are posting here.

Thank you for posting at Dotnetfunda
[Administrator]

Kannan1986, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response