Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Best approach for simple network game

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Well, why don't you look through examples included in synapse library
    Examine these files: synapse40\source\demo\echo\echo.pas & main.pas
    echo.pas should give you idea about how to implement tcp client & tcp server

    To make your applications transfer data over TCP you do not need a web server. Just include code for both server and client parts in your application, then one of users will click "create game" in your app and tell the other one something like "go; I created! IP is 192.168.1.2", so the other one will click "connect" button of his instance of app, enter IP and hopefully it will work lawl. Sever or "Creator" accepts connection, client connects.

    In example source I mentioned above TTCPEchoDaemon class is a primitive server, while TTCPEchoThrd is a primitive client.

    I can give you link to my code, but I doubt it will help you much. I can post the code I already have, but I am too lazy to create a tutorial-example from ground, sry lawl
    https://bitbucket.org/hinst/paslog/s...pas?at=default
    https://bitbucket.org/hinst/paslog/s...pas?at=default
    https://bitbucket.org/hinst/paslog/s...pas?at=default
    These are files I use for my logging library, but not all of them, not sure if it will help.
    BTW I assume u use FreePascal

    u can test everything on one PC at first, use loopback IP address then: 127.0.0.1 or "localhost" to connect
    Last edited by dj_sharp; 20-05-2014 at 08:42 PM.

  2. #2
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    I think I'll have to agree with dj_sharp on that one - synapse and TCP are probably the best way forwards. I've personally played with a few ideas for a data client & server system for use in games and other projects. What worked best for me was to standardize like crazy. And I laid it out like this (first is lowest level, application stuff at the bottom of the list)
    -Common, standard protocol
    -Standard network functions (ie. we send blocks/strings/stuff so that the recieveing command knows what to expect)
    -Protocol encoder (converts the data from the application into packets)
    -Backend (client interface for the client / core server code for the server [think connection management, authorization, protocol negotiation and so on])
    -Custom code.

    As for testing, I run the server on my machine and connect to 127.0.0.1 as dj_sharp suggested. Synapse has some pretty good documentation, but I found the examples most useful IMHO. All that said - I once tried to do all that directly on top of sockets and although I did get it working in the end it was EXTREMELY unreliable and just not nice to use.

    Edit: If you'd like I can PM you the relevant files out of a project of mine (its not open source code yet for a whole bunch of reasons) which is what I use in our ground control software that uses synapse. It isnt the best way to do things but is serviceable.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •