DXSock Version 6.0


  • Cross Platform (Single Source for Windows, Linux and Mac OS X)



Like Kid Rock Says "They say I'm Cocky... it ain't bragging if ya back it up!"
  • High Performance Socket Suite
  • Over a decade of experience
  • Support for SSL/TLS Encrypted Sockets




Delphi XE Support
  • New Unicode Supported
ARM CPU Support
  • (Embedded Linux Drive Array)
Video and Audio Chat
  • Developed Cross-Platform Chat App
Web Based PDF Generator
  • iPhone App uses us for PDF Output




Simple Echo Server


An echo server listens on port 7 for incoming connections. Every character that is received from the client application is sent right back to the client application. This is useful for debugging your first few client applications -- or using telnet to connect to your server and see if everything is getting received correctly. To help explain to people how easy it is to use our product, we have included sample source below.

Free Pascal Source


 Program EchoServer;
 
 Uses
    dxutil_environment,
    dxsock6,
    dxsock_genericserver;
 
 type
    TEvents = object
       constructor Init;
       destructor Done;
       Procedure ProcessSession(Sender:Pointer);
    end;
 
 constructor TEvents.Init;
 begin
 
 end;
 
 destructor TEvents.Done;
 begin
 
 end;
 
 Procedure TEvents.ProcessSession(Sender:Pointer);
 Var
    Session:TBPDXGenericServerSession;
 
 Begin
    Session:=TBPDXGenericServerSession(Sender^);
    While Session.Connected do begin
       If Session.Readable then begin
          If Session.CharactersToRead=0 then break;
          Session.Write(Session.ReadStr(-1));
       end
       else begin
          DoSleepEx(1);
          ProcessWindowsMessageQueue;
       End;
    End;
 End;
 
 var
    Echo:TBPDXGenericServer;
    Events:TEvents;
 
 Begin
    Events.Init;
    Echo.Init;
    Echo.OnProcessSession:=@Events.ProcessSession;
    Echo.Start('',7);  port 7 is the standard echo server 
    Echo.Done;
    Events.Done;
 End.

Delphi Source


 Program EchoServer;
 
 Uses
    dxutil_environment,
    dxsock6,
    dxsock_genericserver;
 
 type
    TEvents = Class(TObject)
       constructor Create;
       destructor Destroy;
       Procedure ProcessSession(Sender:TObject);
    end;
 
 constructor TEvents.Create;
 begin
 
 end;
 
 destructor TEvents.Destroy;
 begin
 
 end;
 
 Procedure TEvents.ProcessSession(Sender:TObject);
 Var
    Session:TBPDXGenericServerSession;
 
 Begin
    Session:=TBPDXGenericServerSession(Sender);
    While Session.Connected do begin
       If Session.Readable then begin
          If Session.CharactersToRead=0 then break;
          Session.Write(Session.ReadStr(-1));
       end
       else begin
          DoSleepEx(1);
          ProcessWindowsMessageQueue;
       End;
    End;
 End;
 
 var
    Echo:TBPDXGenericServer;
    Events:TEvents;
 
 Begin
    Events:=TEvents.Create;
    Echo:=TBPDXGenericServer.Create;
    Echo.OnProcessSession:=Events.ProcessSession;
    Echo.Start('',7);  port 7 is the standard echo server 
    Echo.Free;
    Events.Free;
 End.

Combined Source - using $IFDEF


 Program EchoServer;
 
 Uses
    dxutil_environment,
    dxsock6,
    dxsock_genericserver;
 
 type
 

$IFDEF FPC

TEvents = object constructor Init; destructor Done; Procedure ProcessSession(Sender:Pointer); end;

$ELSE

TEvents = Class(TObject) constructor Create; destructor Destroy; Procedure ProcessSession(Sender:TObject); end;

$ENDIF

constructor TEvents

$IFDEF FPC

.Init;

$ELSE

.Create;

$ENDIF

begin end; destructor TEvents

$IFDEF FPC

.Done;

$ELSE

.Create;

$ENDIF

begin
end; Procedure TEvents.ProcessSession(Sender:

$IFDEF FPC

Pointer

$ELSE

TObject

$ENDIF

); Var Session:TBPDXGenericServerSession; Begin Session:=TBPDXGenericServerSession(Sender

$IFDEF FPC

^

$ENDIF

); While Session.Connected do begin If Session.Readable then begin If Session.CharactersToRead=0 then break; Session.Write(Session.ReadStr(-1)); end else begin DoSleepEx(1); ProcessWindowsMessageQueue; End; End; End; var Echo:TBPDXGenericServer; Events:TEvents; Begin Events

$IFDEF FPC

.Init;

$ELSE

:=TEvents.Create;

$ENDIF

Echo

$IFDEF FPC

.Init;

$ELSE

:=TBPDXGenericServer.Create;

$ENDIF

Echo.OnProcessSession:=

$IFDEF FPC

@

$ENDIF

Events.ProcessSession; Echo.Start('',7); port 7 is the standard echo server Echo

$IFDEF FPC

.Done;

$ELSE

.Free;

$ENDIF

Events

$IFDEF FPC

.Done;

$ELSE

.Free;

$ENDIF

End.

The merged version of the code using compiler IFDEF also points out the slight differences between the compiler syntax for the dialects we use. (Meaning, FPC does have a Delphi Dialect).

Related Keyword:


October 16, 2010
Testing
width 0 cellspacing 0 cellpadding 0 CELL 1 Description of a product image images Thumb SN850940...
September 01, 2010
Recent Questions
Recent Questions Do you still include the source like in the past Yes We include full source code...
August 20, 2010
Revisions Towards Final Release
Revisions Towards Final Release AUGUST 2010 Our multi language resource files have been expanded...
August 18, 2010
Demonstrations
Demonstrations Below is a constantly growing list of demonstrations We are currently developing...
August 14, 2010
Early Release Orders
Early Release Orders Please be sure you have read view June 2010 Release June 2010 Release as this...




Popularity: 3.74% [?]