How to open a raw socket for sending from specific TCP port? I want to have all my connections always go from a range of ports below ephemerals.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are using raw sockets, then just fill in the correct TCP source port in the packet header.
If, instead, you are using the TCP socket interface (
socket(),connect()and friends), then you can set the source port by calling thebind()system call for the client socket – exactly as you would to set the listening port for the server socket.