PocketC TCP/IP server

Discuss PocketC for Palm OS (including Desktop Edition)

Postby shivangp on Thu Mar 04, 2004 11:12 pm

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?
shivangp
 
Posts: 5
Joined: Fri Feb 20, 2004 10:05 pm

Postby dewey on Fri Mar 05, 2004 2:46 am

Can you share your code? Perhaps then someone can tell you what is going wrong.
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby shivangp on Sat Mar 06, 2004 12:01 am

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");
}
}
shivangp
 
Posts: 5
Joined: Fri Feb 20, 2004 10:05 pm

Postby dewey on Sat Mar 06, 2004 3:58 am

sockopen takes a pointer to an int, not an int. So, you code should read:
sockopen(&s);

Jeremy
dewey
Site Admin
 
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby shivangp on Sat Mar 06, 2004 2:35 pm

Thanks dewey that was the problem.
shivangp
 
Posts: 5
Joined: Fri Feb 20, 2004 10:05 pm


Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 2 guests

cron