Jump to content

Example request: I am wanting to have a program listen for and display messages received on a port.


Go to solution Solved by argumentum,

Recommended Posts

I've been trying to word what I need correctly a few times now, and I think I finally have it.
Because I have no idea where to start (The TCP functions are very numerous and I am not sure which of hem helps me do this) I'd like to request a very simple example.

On one end, I want to have my application Program A sitting quietly waiting for a message, any message, to be sent on port - lets say 99. On the other end, a program that sends that message Program B. 
Program A then displays the message that program B sends.

Would someone be willing to write examples for what programs A and B would look like in the least amount of code possible?  I don't want an entire program, I jus want wo working examples that I could work into code for later use. I might use it to send information to the clipboard of my computer in my living room for example.

-Thanks for your time. :)

Edited by Draygoes
Fixed title, added reason.
Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to post
Share on other sites

Ok, that's cool. I've no idea why I didn't realize that works perfectly for what I need? 

Hey, why is TCPShutdown needed? Doesn't that happen anyway when the script exits?

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to post
Share on other sites
  • Draygoes changed the title to Example request: I am wanting to have a program listen for and display messages received on a port.

Just like washing the car, it's gonna rain at some point anyway, right ?
...we do what we must, not just what we need. Unless you need to discover the pain all by your lonesome.

The answer is: do. Do close a TCP/UDP if you opened it. Keep a good coding practice and you'll be a happier coder :)

Think of coding just like medicine or law, is a practice.

Edited by argumentum
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...