Jump to content
Sign in to follow this  
Hest

Find outgoing port

Recommended Posts

Hest

I have made a little piece of software, that sends a string to a train controller. The controller sends back a confirmation and here the problems are beginning.

I have used a packet logger and found out, that my program sendts the string to the correct port, but the outgoing port from the PC is random. The response from the train controller goes back to that random port.

Is it possible to choose what port should be used as outgoing, so that I can listen for a response on the correct port?

I have added a picture as example. PC has ip x.x.x.2, train controller has x.x.x.3 and receives on port 15471

My program sends the string from port 51277 to 15471 and the controller sends back from 15471 to 51277, but because 51277 is random, my program don't know what port to listen on..

Any help is very appreciated

post-33176-1216988274_thumb.jpg

Edited by Hest

Software:Model Train Calculator (Screen)Autoit3 beginner!

Share this post


Link to post
Share on other sites
ProgAndy

You don't need to know the port. the connection established by

$Connection = TCPConnect(...,...) is bidirectional.

To send, use TCPSend($Connection,...)

And receive with $data = TCPRecv($Connection,2048)


*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites
Hest

Edit: Working now, I made a mistake. Sadly I don't remember exactly what it was.

Edited by Hest

Software:Model Train Calculator (Screen)Autoit3 beginner!

Share this post


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
Sign in to follow this  

×