Page 1 of 1

PostPosted: Thu Mar 04, 2004 11:12 pm
by shivangp
I do I create a basic TCP/IP server with pocketc's new network functions? Whenever I try to use sockbind or socklisten I get a fatal error message saying invalid handle value when I execute the program. Can anyone give an example of a server?

PostPosted: Fri Mar 05, 2004 2:46 am
by dewey
Can you share your code? Perhaps then someone can tell you what is going wrong.

PostPosted: Sat Mar 06, 2004 12:01 am
by shivangp
Sure here is what I have, I get the error even before the "Before bind gets put in" if anyone can see what I'm doing wrong please let me know

#include "../UtilCode/neterror.h"

main() {
int err, s;

string name, addr, index;
puts("Started\n" );
err = netopen();
if (err == 0) {
puts("net opened");

if (sockopen(s)==0)
{
puts("before bind");
if (sockbind(s, ":2600") == 0)
{
puts("binded");
if(socklisten(s, 1) == 0)
{
puts("listening");
}
}
}
} else {
puts("Failed to open network: " + neterror(err) + "\n");
}
}

PostPosted: Sat Mar 06, 2004 3:58 am
by dewey
sockopen takes a pointer to an int, not an int. So, you code should read:
sockopen(&s);

Jeremy

PostPosted: Sat Mar 06, 2004 2:35 pm
by shivangp
Thanks dewey that was the problem.