Yes, TCP ports are bi-directional. Remember, as I mentioned, these are network ports. So the code to send data to/from a TCP port using TARGET is very similar to the code you would use to send/receive data via an Ethernet or WiFi TCP port. Or more correctly, TCP is a protocol on top if IP (hence the term TCP/IP). IP is a protocol on top of the hardware interface (Ethernet, WiFi, Bluetooth, etc.). So the TCP protocol doesn't understand what hardware it is communicating on. It just understands that a message is to be send or received from a TCP port, and it uses an IP address to do that. For communication between two applications on the same computer, the IP address is 127.0.0.1, and you define the TCP port when you set up the channel (e.g. 127.0.0.1:51850). Many TCP ports are pre-defined such as HTML uses :8080, and email often uses :993 to receive email, and :25 to send mail.
These ports are bi-directional.
To learn more, look at examples of sending TCP packets using C++ or C in general from Microsoft's developer sites. There are probably a few examples doing bi-directional communication with various server types like HTML, but also generic communication where you define the format of the packet yourself. And since this is TCP, it is all part of IEEE 802.11, an term you may have heard about.
Then to translate all this into TARGET, you have to load the Windows library (.DLL) that deals with TCP packet communication and then you will have access to the same library routines in TARGET used by the C language examples you find at Microsoft's web site or elsewhere.
A few additional comments:
The two comands you need from TARGET to make this work are:
From the TARGET sys.tmh file:
Use this to load the Windows LIbrary (.DLL) for the TDP protocol. I believe this works similar to the Windows LoadLibrary() command. But Thrustmaster had to include their own instead of using the Windows version.
int LoadLibrary(alias filename){}
From the target hid.tmh file:
Use this command to create the TCP or UDP port, but you have to do some other commands to finish setting up the port.
//Creates a server on the specified port to process external data
//port - the port number used by the server
//useUDP - 0(default) to use TCP protocol, 1 for UDP datagrams
//interface - 0(default) to install the server on the local interfaces,
// a string IP address to use the corresponding interface only
//NOTE: TCP needs 2Bytes at the start of each frame indicating the size of the packet ( 2 + size of data that will follow)
// this information will not be passed to the callback, but it is needed to separate the frame from the stream
// (the size info can be added to the data buffer or with a separate call, before sending the data)
// UDP sends the whole packet in one chunk, no extra size information is needed
// maximum data size is limited to 4096Bytes
int InitSocketServer(int port, int useUDP=0, int interface=0){}
These protocols can also due UDP. UDP is a simpler method of communication. Both work on top of IP.
Using TCP should work very similar in TARGET as it works in the Windows programming examples, but in TARGET, it must work within the constraints of TARGET. For example, TARGET does not understand the concept of a string. There is type char (a single byte), but strings as defined normally in C do not work in TARGET. Instead, you must use the &name convetion. Like throughout TARGET, we say &Joystick or &HCougar. It is too much to get into that in this emai, but in simple explanation, if you want to use strings, you must allocate memory and reference them with pointers (similar to C), but & is not a pointer in the normal sense. It is called a type alias. The alias is kind of like a C pointer, but & and * aren't the same. I can help with this more later, but review how & is used in the target.tmh file. That is where I figured it all out. If you don't need to send strings, but numbers or char is good enough, you can avoid all that mess with &. Or you might be able to use printf() to send text strings through TCP the same way we use it to print to the console, or print to a file.
This is all getting to somewhat deep understanding of C programming, not novice level stuff. Not sure your level of understanding, but the more you understand about C (or C++), the easier this will be. Don't be afraid to dive in.