Game Development Community

Usage of TCPObject from C++ - how?

by Thomas \"Man of Ice\" Lund · in Technical Issues · 03/13/2003 (9:03 am) · 3 replies

I've searched everywhere and I simply cant find any example code or explaination of how to use the TCPObject class.

What I would like to do is to open a conn to a server I got, send a command message and read the result.

I've tried doing this:
TCPObject* tcp = new TCPObject();
   tcp->connect("192.168.1.10:7777");
   char buffer[1024];
   dSprintf( buffer, sizeof(buffer), "Test");

   tcp->send((U8*)buffer, dStrlen(buffer));

   tcp->disconnect();
   dFree(tcp);
   dFree(buffer);

This compiles, but never sends anything - my server application at least does not display any incomming connections (works with a telnet to the port)

Does anyone have a resource, URL or anything to help me get going on this?

I dont want the code to be scripted, as I'm trying to write some authentication/login/logout code against a login server.

#1
03/13/2003 (9:30 am)
I'm not familiar with the class, but it could be that it has a flushing mechanism whose threshold you aren't meeting, try forcing a flush.

just a random thought

-brad
#2
03/16/2003 (11:59 am)
Bump (sorry) - no "flush" command found. But good thought.

Does anyone know if the code even works in HEAD?
#3
03/16/2003 (1:04 pm)
I got this working via script. Here's a resource that helped me. http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=3176. As I recall, it is very picky about how the address and or URL's in particular query strings and the like. I was using apache web server, and PHP. It's been a while since I looked at any of this. Enjoy the link.

Robert