Click here to Skip to main content
15,903,012 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello guys

I am creating a wpf application in which I connect to android application through TCP listener. I made a separate class for tcp listener because i wanted to call it from all wpf forms.So till now its working fine from my main form but when i call tcp listener from another form i got an error i.e "Port is in use and only one port is permitted to use". If you have any solution please let me know..My code is


IPAddress localAddr = IPAddress.Parse(localIP);

TcpListener server = new TcpListener(localAddr, Port);
server.Stop();
server.Start();

it works from Main form but when I call it from another form the error occurs.
Any suggestion and solution is welcome.
Posted
Updated 15-Dec-16 4:46am
Comments
Prasad Khandekar 22-Nov-13 8:26am    
You can not have multiple listeners for same port. Are u sure about your code.
RAHUL(10217975) 22-Nov-13 9:12am    
I have one tcp listener in my class . I am not creating instance when i am calling from different forms but i am getting this error too "A blocking operation was interrupted by a call to WSACancelBlockingCall"..I am using thread to start tcp listener .
Sergey Alexandrovich Kryukov 22-Nov-13 9:40am    
Form or not form, does not matter. You use some symbols which are not declared in some scope, so what do you want?
And what are the "Form", in WPF?
—SA
RAHUL(10217975) 23-Nov-13 3:16am    
Hey I got it I have created different windows service for android communication.

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