mike55 Posted March 9, 2005 Posted March 9, 2005 Hi all, Have written a simple TCPServer, see code below, that is suppose to listen at a certain port for a message and print that message. If I use for example port 8001, then the code works perfectly. However I need to listen to port 80, for an email with a specific header. When the email with the correct header is received at port 80, I need my code to respond in a specific manner. The problem is that when I try and connect to port 80, I get the following exception: Error..... at System.Net.Sockets.Socket.Bind(EndPoint localEP) at System.Net.Sockets.TcpListener.Start() at TCPServer.Form1.btnServer_Click(Object sender, EventArgs e) in c:\documents and settings\modonnell.itec\my documents\visual studio projects\tutorials\c-sharp\tcpserver\form1.cs:line 98 Any suggestions on why this problem is occuring, I think it might be to do with security related issues. Mike55. try { IPAddress ipAD = IPAddress.Parse("xxx.xxx.x.x"); TcpListener myList = new TcpListener(ipAD, 80); myList.Start(); Console.WriteLine("The server is running at port 8001"); Console.WriteLine("The local End point is : "+myList.LocalEndpoint); Console.WriteLine("Waiting for a connection."); Socket s = myList.AcceptSocket(); Console.WriteLine("Connection Accepted from : "+ s.RemoteEndPoint); byte [] b=new byte[100]; int k=s.Receive(b); Console.WriteLine("Received..."); for (int i =0; i<k; i++) Console.WriteLine(Convert.ToChar(b[i])); ASCIIEncoding asen=new ASCIIEncoding(); s.Send(asen.GetBytes("The string was recieved by the server.")); Console.WriteLine("\nSent Acknowledgement"); s.Close(); myList.Stop(); } catch (Exception a) { Console.WriteLine("Error..... " + a.StackTrace); } Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Administrators PlausiblyDamp Posted March 9, 2005 Administrators Posted March 9, 2005 Is IIS running on the PC? If so then it will be using port 80. Why are you expecting an e-mail on port 80 anyway? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mike55 Posted March 9, 2005 Author Posted March 9, 2005 Is IIS running on the PC? If so then it will be using port 80. Why are you expecting an e-mail on port 80 anyway? My fault, got the port numbers mixed up, need to listen to port 25 and 110. Can connect to and listen to 110, but not 25. Any suggestions?? Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Administrators PlausiblyDamp Posted March 9, 2005 Administrators Posted March 9, 2005 Again does the PC have the SMTP service running? If so it will grab port 25. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
mike55 Posted March 9, 2005 Author Posted March 9, 2005 Again does the PC have the SMTP service running? If so it will grab port 25. Ok, see what you mean. Is it anyway possible for my program to share port 25 with ISS SMTP?? Mike55 Quote A Client refers to the person who incurs the development cost. A Customer refers to the person that pays to use the product. ------ My software never has bugs. It just develops random features. (Mosabama vbforums.com)
Administrators PlausiblyDamp Posted March 9, 2005 Administrators Posted March 9, 2005 Only one service can use a port at any one time. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Mister E Posted March 10, 2005 Posted March 10, 2005 Ok, see what you mean. Is it anyway possible for my program to share port 25 with ISS SMTP?? Mike55A port is virtual. It is simply a "process identifier" -- meaning it can only identify a single process at a time. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.