I know that it is not easy to bind a port number to TCP socket that you would use to send data (because systems usually bind a random port to sockets).
But I read on one article that by using some low level networking methods you can bind a port number to a TCP socket then use it to send data ?
Does anyone has an idea about how that could be done ?
I am using c programming language
Actually it is quite easy. Simply use the bind function as you would for a server.
You can simply call
bind()
beforeconnect()
in a client in the same way that you would callbind()
beforelisten()
in a server. There is nothing more complicated to it than that.Bind it before connecting.