OpenTransport problem in X

Tobi
Unregistered
 
Post: #1
Hi folks,

for my game engine I'm currently writing the server/client stuff for multiplayer using OpenTransport.
I use CarbonLib 1.6 and MPW to compile.

In OS 9 server and client work well, but in X the server doesn't work properly. I'm using a connection-based transactionless, asynchronous and blocking endpoint with a notifier.
The endpoint is created successfully but OTBind() won't work. It doesn't return an error, but when I check the endpoint state it is still T_UNBND and not T_IDLE as it should be. This only happens if a pass an address in the OTBind() call like:
Code:
TBind binder;
InetAddress ina;

ina.fPort=23;//like telnet
ina.fHost=0;//myself
ina.fAddressType=AF_INET;

binder.qlen=1;//1 outgoing connection request
binder.addr=(UInt8 *)&ina;
binder.len=sizeof(InetAddress);

OTBind(myEndpoint, &binder, NULL);

If I just use OTBind(myEndpoint, NULL, NULL); it works well, but that way I cannot do a server because no address was specified.
I cannot see where the problem is. I've looked at Apple sample code as well as the source of OTChat and the OpenTransport documentation. They use just about the same code and it works.
Any idea what I might be doing wrong???

-Tobi
Quote this message in a reply
Tobi
Unregistered
 
Post: #2
Ok, now I know what I've done wrong.
I rewrote the app from scratch with 100% error checking and I got a error -3212 in OTBind() which is an access denied error. I got this error when trying to bind to port 23 (telnet) or port 80 (HTTP, web). Then I tried a much higher port number, like 49123 and then it worked. That made me think I don't have the needed access permissions for some of the ports so I logged in with the "root" user. Voila! Also port 23 and 80 worked.
I'm now using a higher port for my server so the user doesn't need to be root to use the game, but there has to be a way to open those ports 23, 80 or ftp port on OS X without being superuser or it wouldn't be possible to run a normal server without being root.

So does anyone know a way to change the access permission for the ports?

Thanks,

-Tobi
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
The normal servers all do run as root... at least initially.

It's < (or equal?) 1024 that's reserved for root.

Configuring the firewall settings is unlikely to be much fun in 10.1 -- I suspect it'll mean messing around in NetInfo.

It looks like 10.2 has a nice GUI for doing this.

Why do you care that you're on a low port number, though? Quake 3 doesnt!
Quote this message in a reply
Tobi
Unregistered
 
Post: #4
Thanks for your info, OneSadCookie. I found a good port now that's > 1024. Smile

Quote:Why do you care that you're on a low port number, though? Quake 3 doesnt!

I don't care really. High port numbers are ok. It would just have been cool if it could run on the telnet port so I could have done some tests with telnet.
But I've found a better telnet client now which supports custom port numbers so this isn't a problem anymore.

By the way, your QTValuePak 2 really rocks. Thanks for that great piece of work!

-Tobi
Quote this message in a reply
Post Reply