Results 1 to 7 of 7

Thread: Help with sockets

  1. #1
    Join Date
    Jun 2009
    Location
    Hiding
    Posts
    160
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Exclamation Help with sockets

    so i dived in to sockets to play with them but i cant figure them out can anyone help me with a server and client setup though sockets

    edit: if this doesnt go here move it.
    Last edited by austin2162; 08-18-2011 at 05:35 AM.
    ~Austin~

  2. #2
    Join Date
    May 2007
    Posts
    527
    Mentioned
    12 Post(s)
    Quoted
    109 Post(s)

    Default

    Quote Originally Posted by austin2162 View Post
    so i dived in to sockets to play with them but i cant figure them out can anyone help me with a server and client setup though sockets

    edit: if this doesnt go here move it.
    What language? If C++, Boost's ASIO is too cool.

  3. #3
    Join Date
    Jun 2009
    Location
    Hiding
    Posts
    160
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    in simba.
    ~Austin~

  4. #4
    Join Date
    Jan 2011
    Location
    Denver, CO
    Posts
    1,351
    Mentioned
    2 Post(s)
    Quoted
    72 Post(s)

    Default

    Have you read this yet?

  5. #5
    Join Date
    Jun 2009
    Location
    Hiding
    Posts
    160
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i did read that but im still struggling
    ~Austin~

  6. #6
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Well, I can't provide you with a fully working example right away. But something to get you started:

    SocketClient:

    Simba Code:
    program new;
    var sock: integer;
    begin
      sock := CreateSocket();
      ConnectSocket(sock, 'localhost', '9001');

      sendsocket(sock, 'hi'#10#13);
      closesocket(sock);
    end.

    Tested with: (run the nc command first, not sure if Windows has something similar)

    Code:
    $ nc -l -p 9001 localhost
    hi
    E: Netcat for windows: http://joncraton.org/blog/46

    Server:

    Simba Code:
    program new;
    var
      serv, sock: integer;
      s, ip, port:string;
    begin
      serv := CreateSocket();
      setsockettimeout(serv, 50000);
      BindSocket(serv, '0.0.0.0', '1504');
      ListenSocket(serv);;

      sock := AcceptSocket(serv);
      setsockettimeout(sock, 50000);

      writeln(recvsocketstr(sock));
    end.

    Tested with telnet:
    Code:
    $ telnet localhost 1504
    Trying 127.0.0.1...
    Connected to localhost.
    Escape character is '^]'.
    HELO
    Connection closed by foreign host.
    Compiled succesfully in 100 ms.
    HELO
    Successfully executed.
    Hope it helps. I didn't fully figure it out myself yet. Dgby knows a lot more on this.
    Last edited by Wizzup?; 08-20-2011 at 09:23 AM.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  7. #7
    Join Date
    Sep 2011
    Posts
    3
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    And if you mean player information. Yes, I already have some functions started for it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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