#pragma library( "ascom10.lib" ) PROCEDURE MAIN LOCAL o,x,buf := "" o := CreateObject( "MSWinsock.Winsock" ) o := o:dynamicCast( "ActiveXObject" ) o:DataArrival := {|nBytes|_dataArrival(nBytes,o)} o:ConnectionRequest := {|nRequestID|_ConnectionRequest(nRequestID,o)} o:LocalPort := 1007 o:protocol := 0 print('LocalHostName: ',o:localHostName) print('LocalIP: ',o:localIP) print('Listening on port: ',o:LocalPort) o:Listen() // o:AboutBox() // if you like... ? ? "Press ESC to terminate." while .t. if (x := inkey(0.01)) == 27 ; exit ; endif if x != 0 buf += chr(x) ?? chr(x) if o:state == 7 o:sendData(buf) buf := "" endif endif enddo o:close() RETURN function print(cDsc,xVal) ? cDsc ?? xVal return nil function _dataArrival(nBytes,o) local i,s := s := space(nBytes) o:getData(@s) ?? s return nil function _ConnectionRequest(nRequestID,o) print('request: ',nRequestID) print('from: ',o:RemoteHostIP) if o:state != 0 ; o:close() ; endif ? o:Accept(nRequestID) o:sendData("Connection accepted...") return nil