Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Network Programming

Options
  • 22-02-2001 11:28am
    #1
    Registered Users Posts: 4,676 ✭✭✭


    Howdy,
    I was wondering if anyone has any info as re networking programming in c/c++. Specifically and good books that they recommend or websites ?

    I've done a few searches on google, and cant really find too much. Humm.... just thought of something. I better go try search for socket programming.

    Gav


Comments

  • Registered Users Posts: 432 ✭✭Catch_22


    beej's guide to socket programming is a very handy intro to tcp sockets in c

    you should find it thru any search engine

    c22


  • Registered Users Posts: 380 ✭✭dogs


    if you want some more examples, take a look at rootshell.com
    they're generally *bad* examples, but they'll give you a good idea of how to go about things
    especially with the funkier socket flavours


  • Closed Accounts Posts: 218 ✭✭Void


    I can't recommend any good links unfortunately. But I can help you with any problem you could possibly encounter with socket programming.
    Send me a mail, and I'll give you the Void UDP module. It has some TCP as well, but alkshdlkashdkahs. Complicated. I pretty much know all there is to know (!not true!) about UDP/TCP. The code sucks, but should serve as a good example of how to implement a multiplayer game/any other kind of networked application you would care to name. No multithreading as yet (big flaw, I know...).

    Dogs: Rootshell.com is a kiddie hax04 site. The code there is all "raw sockets" and has no bearing on real network programming. Unless you want to be l33t of course.


  • Registered Users Posts: 380 ✭✭dogs


    Dogs: Rootshell.com is a kiddie hax04 site. The code there is all "raw sockets" and has no bearing on real network programming. Unless you want to be l33t of course.

    They're not all raw, and I did mention 'funkier flavours'. Real network programming ? *sigh* He wanted examples of socket code ...


  • Registered Users Posts: 3,308 ✭✭✭quozl


    void where did you learn your network codeing from? I want to write a client/server program. I used to code muds, but the network code was fortunately nicely modularised out, and I didnt need to tinker with it. I need to run a server, that can handle multiple clients (32 say) and it needs to be nonblocking.
    Do you know of any good examples of this sort of thing. I have read beejs networking guide, but I'd like something a bit more complete to take apart.
    quozl


  • Advertisement
  • Registered Users Posts: 897 ✭✭✭Greenbean


    Non-blocking is where your complications start. What protocol are you using? Tcp/ip or udp. Shall it be connectionless (with only 32 clients it wouldn't need to be really - it could be pseudo-connectionless).

    for c/c++ tcp/ip networking you should use the sockets stuff as described by beej's guide. You've also got to set the sockets to non-blocking. Then you can use the c "select" command to announce that new data has arrived from any of the sockets looked after by that select command.

    Unfortunately if only a tiny bit of the message you were expecting has been received the select command will still announce that new data has arrived and return this incomplete message back to the program. To overcome this you should send each piece of data with its size in bytes in the first 4 bytes of the message. The select can then receive data continuously and buffer it, one buffer for each socket, and keep checking if a full message has been formed on any of the socket buffers. When it finds one it returns this to the program.

    Non-blocking I/O requires this sort of thing.


  • Closed Accounts Posts: 218 ✭✭Void


    Greenbean pretty much said everything there.
    First of all, decide whether it's going to be TCP or UDP. My stuff is mostly UDP (using select()). So it's non-blocking anyway. I use TCP to handshake only upon connection. I'm thinking of using TCP to pass special "messages" to clients, stuff that has to be guaranteed to get through, but isn't critical like maneuvring data. Dunno if this idea has any merit smile.gif
    If you want rock solid TCP examples, I recommend you download the original DIKU mud source code. It does exactly what you want. If you want something really hardcore, do a search for a game called "Golgotha", it's development team went bankrupt near the end of the project, and they released their source code into the public domain. It's very complex though. I built my network code on a UDP peer-to-peer client-side prediction example that some bloke did for their final year project. I've lost the link though, but do searches for "multiplayer udp client-side prediction" etc and you might find something.


  • Registered Users Posts: 16,413 ✭✭✭✭Trojan


    Tannenbaum is *the* network book, he's the K&R equivalent. It doesn't have much programming related stuff, but it's a good buy & handy to have when you are.

    My lecturer has this book:

    Internetworking with TCP/IP, Vol. 3: Client-Server Programming and Applications, Linux/Posix Sockets Version

    http://www.amazon.com/exec/obidos/ASIN/0130320714/qid=983354742/sr=1-3/ref=sc_b_3/104-9656457-6705536

    I've had a fair look through it, it's very good (check the reviews).

    Al.


  • Registered Users Posts: 194 ✭✭Sputnik


    If you want microsoft specifc info. Network Programming for Microsoft Windows is very good.


  • Registered Users Posts: 4,676 ✭✭✭Gavin


    Aye,
    I have tanenbaum or however it's spel alright. Good book, just need to read it more. So much stuff to read smile.gif

    Thanks for the tips one and all.

    Gav


  • Advertisement
  • Registered Users Posts: 3,308 ✭✭✭quozl


    I cant find that tannenbaum book on amazon. Whats its full name? Anyone know? I've trawled through hodges figis and waterstones for network programming books, but they dont have any.
    quozl


  • Registered Users Posts: 932 ✭✭✭yossarin


    "Computer Networks, 3rd Ed."

    http://www.prenhall.com/tanenbaum/

    I got it in Waterstones


  • Registered Users Posts: 1,481 ✭✭✭satchmo


    That'd be 'Computer Networks' by Andrew S. Tanenbaum. Good reference book, it was our Communications book for 1st year. As far as I know they're still using it, so Hodges Figgis probably have a few copies in-store. Won't be much help if you're looking for code though, just theory.


  • Registered Users Posts: 3,308 ✭✭✭quozl


    thanks lads. I'll go have a look at it. Found a book by stevens on amazon that got good reviews, might buy that. cheers
    quozl


  • Registered Users Posts: 16,413 ✭✭✭✭Trojan


    Tanenbaum is on a 4th Edition at this stage (I've 3rd meself) but just so's ye know! smile.gif

    Didn't notice any major diffs but only had a quick look at 4th...

    Al.


  • Closed Accounts Posts: 557 ✭✭✭Snaggle


    If the Stevens book you are ferring to is Unix Network Programming, then you should most definitely get that, preferably 2nd edition volume 1 (which covers all aspects of socket programming as well as raw packet access, packet capture and IPV6) as opposed to Unix Network Programmins 1st edition (which covers a lot of obselete protocols and is incidentally the Unix book geek girl carries in Wayne's World 2).


  • Registered Users Posts: 16,413 ✭✭✭✭Trojan


    and is incidentally the Unix book geek girl carries in Wayne's World 2

    You need to get out more.

    A lot more...

    Even Jaden thinks so! smile.gif

    Al.




    [This message has been edited by Trojan (edited 08-03-2001).]


  • Registered Users Posts: 3,308 ✭✭✭quozl


    Cheers Snaggle,
    ordered it from amazon 2 days ago. Glad to see it was a good choice smile.gif
    quozl


  • Closed Accounts Posts: 557 ✭✭✭Snaggle


    <font face="Verdana, Arial" size="2">Originally posted by Trojan:
    and is incidentally the Unix book geek girl carries in Wayne's World 2

    You need to get out more.

    A lot more...

    Even Jaden thinks so! smile.gif

    Al.
    </font>

    I went out to see Wayne's World 2... then bought the Unix book


  • Closed Accounts Posts: 1,460 ✭✭✭DipStick McSwindler


    This post has been deleted.


  • Advertisement
  • Registered Users Posts: 1,922 ✭✭✭fergalr


    Sorry to resurrect an extremely old thread here, but does anybody have an update on good Network Programming tutorials in C?

    I have to make an instant messaging client server program and im completely lost

    Help is much appreciated

    Thanks

    IrishFeeney92 :D

    I'm not sure it will have changed very much in the last decade.

    You could do worse than starting out with Beej's guide.


  • Registered Users Posts: 16,413 ✭✭✭✭Trojan


    Jaysus, talk about resurrecting an old one...

    Well, I've still got that Tannenbaum 3rd Edition if anyone wants to borrow it!


  • Registered Users Posts: 40,038 ✭✭✭✭Sparks


    Well, some stuff will have changed (things like openflow, netmap and the like have given some new networking ideas) but that stuff's pretty esoteric and aimed at very high bandwidth or very specialised applications. For a basic IM program (and I'm assuming this is a college exercise because I can't think of why anyone would be trying to make one as a product these days), basic reference implementations for either TCP or UDP sockets will do the job perfectly well. Tanenbaum or Stevens (or heck, even the man pages) will cover most of it and you'll find dozens of tutorials via google very easily -- Beej's guide is a good example.

    Also, holy heck but that's a record attempt for resurrection of a zombie thread :D


  • Registered Users Posts: 1,572 ✭✭✭kyote00


    The Stevens book is probably the best one .

    Also check out WebSockets as a 'modern' way to perform non blocking, event driven IO
    (socket.io and websocket.org and the node.js platform)


  • Registered Users Posts: 232 ✭✭lemon_remon


    I was reading this thread thinking "the **** is everyone doing screwing around with low level networking sockets". Now, I feel young.


Advertisement