simple networking

Started by
13 comments, last by crazy_andy 19 years, 3 months ago
I've been away for abit, but now I'm back and thinking of a new project. I was thinking of trying to do something multiplayer. my first idea, is to have a text file on one computer, and another computer be able to add/read lines from this file. If you have asny good tutorials on this matter, please post them
www.stickskate.com -> check it out, some gnarly stick skating movies
Advertisement
We have quite a few networking articles in our Multiplayer and Networking section of articles and resources. In particular, beej's guide is a fairly good introduction to sockets programming.
cheers
www.stickskate.com -> check it out, some gnarly stick skating movies
There's also OpenTNL which is the networking part of the torque engine released under the GPL. If you use this you can have a decent networking library and concentrate on your game rather than trying to get networking code working.
Id perfer to learn the code, no real reason, I just like to know what Im doing.

The beej tut isn't too usefull, as he is programming in unix, rather than windows, but I found another one at http://www.frostbytes.com/~jimf/papers/sockets/winsock.html

I have code for both a client and a server now: the server sets up and then uses the accept command to wait for a connection from the client. I then run the client program, which connects to the server (I think it does anyway) and tries to send some data. I get no errors, but the server program doesn't seem to respond or run the next line of code, MessageBox(...).

What I need is some source code, for both the client and the server, that uses the:

listen
accept
connect
socket

commands, If any one has some good code, please post it up.
www.stickskate.com -> check it out, some gnarly stick skating movies
Quote:Original post by crazy_andy
The beej tut isn't too usefull, as he is programming in unix
It's largely the same.
Quote:Original post by crazy_andy
What I need is some source code, for both the client and the server, that uses the:

listen
accept
connect
socket

commands, If any one has some good code, please post it up.
Which language? C++?
I've got the basics now anyway, its just getting it to work properly. yes c++ is what Im using.
www.stickskate.com -> check it out, some gnarly stick skating movies
it's as good as the same really, and he added the names of the commands to call on windows, so beej2win
---Yesterday is history, tomorrow is a mystery, today is a gift and that's why it's called the present.
I found my problem, the accept function:

new_sock = accept(s,NULL,NUL);

The problem is that the code gets to this line and doesn't continue. from several sources I have found people saying that the function will wait for a connection for a couple of seconds and then will return an error if there has not been one recieved. However my code just stops on this line.

anyone have any ideas what is goin on.
www.stickskate.com -> check it out, some gnarly stick skating movies
Ok, I have found loads of examples using the same code as me, which seem to work, but mine still doesn't work.

On msdn it says the server requires NT or Windows server something. Does that mean I can't use the commands: accept, listen ... when having two computers connect, both on XP.

Also what type of app should it be, console, win32, win32 console ...

I really appreciate all the responses I have allready recieved, and any I get, because I have never worked with networking before.
www.stickskate.com -> check it out, some gnarly stick skating movies

This topic is closed to new replies.

Advertisement