Hi, I was wondering how to make a program listen on a port... lests say port 54321. All I want for it to do is listen for any message sent on that port, and then output "54321"... Is this as simple as I think, or is it something that is going to require a lot more knowledge of tcp/ip and such? If you cannot answer my question on your own, can you at least point me towards a tutorial or something?

Thanks much!

Recommended Answers

All 2 Replies

Try Reading Socket Programming.

what you are actually doing is creating a server listening on Port, this can be achieved using WinSock on windows Plateform, same can be done on linux using the socket API defined for linux.

int main ()
{
   // Initialize the Socket Environment.
   // Create Server side Socket.
   // Define Address information & Port.
   // Bind to that information.
   // Start Listening on specified information.
   // Upon Connection Get the Information.
   // Process the Information.

   return 0;
}

hope the above alogirthm might help you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.