Results 1 to 5 of 5

Thread: Any easy to use net library?

  1. #1

    Any easy to use net library?

    I need some noob-friendly network library. One that would do most of hard stuff like making connection and resending UDP packets if it is UDP connection, leaving only sending actual network messages to programmer.

    So I could write (in pseudocode) something similar to this:
    Code:
    TCPconnection:=connect_tcp(ip_or_url,port);
    UDPconnection:=connect_udp(ip_or_url,port2);
    SendString_tcp("Hai, I'm TCP packet!");
    SendString_udp("Hai, I'm UDP packet!");
    closeTCP(TCPconnection);
    closeUDP(UDPconnection);
    and from server side
    Code:
    TCPconnection:=connect_tcp(ip_or_url,port);
    UDPconnection:=connect_udp(ip_or_url,port2);
    while (tcpPacketsInQueue(TCPConnection)) do begin
      packet:=GetTCPPacket;
      writeln(packet.value);
    end;
    while (udpPacketsInQueue(UDPConnection)) do begin
      packet:=GetUDPPacket;
      writeln(packet.value); //packet.value would be variant.
    end;
    closeTCP(TCPconnection);
    closeUDP(UDPconnection);

  2. #2
    That is what nxPascal network class is made for. I needed solution that works both on Delphi and Lazarus, so i went with underlying synapse library. There's demo with my engine that can switch between TCP/UDP mode on the fly, and send/receive text and binary messages. They are very easy to use classes.

    As far as its testing goes, i have a small game of top-down view ships, controlled with keys. On my local computer i can start over 4 windows of it, and all the ships move in perfect sync on all game windows. There was noticable lag with international TCP connection, but i suspect i didn't do necessary lag predictions or something. But that's game mechanics, not engine's fault. I should still do a filetransfer test sometime to be sure it's working without error.

    Additionally couple packets are sent at first to boot all unwanted connections, kind of authentication to network. Second feature is that you can mask-encrypt all data that is sent. It is very fast xor-operation.
    Last edited by User137; 03-06-2013 at 11:19 AM.

  3. #3
    Will it work without rest of nxPascal? I prefer Allegro for doing most of things and would use only network bits of nxPascal - I don't want to bring any unnecessary code into my game.

  4. #4
    Yes, i tried to make everything modular. nxNetwork is standalone, using only synapse
    https://code.google.com/p/nxpascal/s.../nxNetwork.pas
    Code:
    uses {$IFDEF UNIX}cthreads,{$ENDIF}
      Classes, SysUtils, synsock, blcksock;
    ...
    (and uses Math; for implementation)
    More testing for it would be welcome.

  5. #5
    i'm using lnet, not sure if it's 'easy' yet

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
  •