Selecting port for sending data on TCP layer

I written a C program for sending and receiving a data on the TCP layer. I have created a socket for sending and receiving a data over a specific IP address. Question : How to identify the free IP address and port number on the laptop ?? So that I can use it for communication. I am using windows 7 operating system.

Solutions

what is the name if the port is free (example : close wait, time wait, established , listening ) ??

LISTENING is ports that other servers are using. The rest are usually ephemeral ports used by clients. – Barmar

Tags: C / Tcp / Port

Similar questions

Rewriting Live TCP/IP (Layer 4) (i.e. Socket Layer) Streams
I have a simple problem which I'm sure someone here has done before... I want to rewrite Layer 4 TCP/IP streams (Not lower layer individual packets or frames.) Ettercap's etterfilter command lets you perform simple live replacements of Layer 4 TCP/IP streams based on fixed strings or regexes. Example ettercap scripting code: http://ettercap.sourcef...
Does UIView .layer CALayer begin with a layer?
For a little project to become a more optimized efficient programmer for the upcoming iPhone game I'm making, I'm trying to make a user interactive interface, but it's difficult. In my last question posted yesterday I asked about improving my ability to modify events of a UIImageView, and UIView to accept touches, (and it's working quite well!) Tho...
How do I get network layer and transport layer protocols from a pcap in C?
I am working on an assignment that has me parsing information from a pcap file in C using the libpcap library. I have had success in figuring out how to get data such as the source/dest ip addresses, tcp/udp ports, and source/dest ethernet addresses. Next on the list is to get stats from network and transport layer protocols seen and how many packe...
Why an extra layer(HAL) between library and kernel layer?
For Linux OS running on x86 hardware, to invoke TCP_listen() that is part of TCP/IP driver(for x86) in kernel, user space client application calls listen() interface which is part of user space glibc library[GNU distri.]. listen() in turn calls sys_Listen() before entering into kernel mode via INT 0x80 software interrupt for invoking kernel mode TC...
How to call Delphi function (upper layer) from C (lower layer), which is built in libXXX.so?
I have a FMX project running on Android. I can make the FMX project execute a C function in “libTest.so” as follows: main.pas: TestC.c: I want the C function “RegisterCallback” in “libTest.so” to keep the Delphi function pointer of “MyCallbackFun”, then at certain time (such as a timer expiration) the “libTest.so” can call the function pointer with...
Pass the frame from the Link layer to the Physical Layer
I'm trying to create a simple Link layer protocol for school. I've been searching and googling and I understand that Link layer has pas the frame I create to the Physical layer, but how to do in Programming (language c) is there a function or library that I can use to send my frame directly using Physical layer ? or how should it be done ?

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.