[Gambas-user] UNIX SOCKETS

Chris Dunworth dunworthsys at ...626...
Fri Apr 2 23:34:48 CEST 2010


Hi All,

Don't know if I'm doing something wrong or there is a bug

Using Gambas 2.16  on SLAX 6.1.2  Linux Kernel  2.6.27.27

Graphical application with Network programming option

My class file
****************************************************************************************************
 Gambas class file

PUBLIC MySock AS Socket

PUBLIC SUB Button1_Click()

  DIM sBuf AS String

  MySock = NEW Socket
  'MySock.Connect("localhost", 8080)
  MySock.Connect("/var/run/gtm2")

  PRINT "status1" & MySock.Status


  DO WHILE (MySock.Status <> 7) AND (MySock.Status > 0)
    WAIT 0.1
  LOOP
  PRINT " Status = " & MySock.Status

  IF MySock.Status <> 7 THEN
    PRINT "Error <>7 " & MySock.Status
    QUIT
  END IF
 PRINT "socket opened"

  sBuf = "Hello over there.\n"
  WRITE #MySock, sBuf, Len(sBuf)

  DO WHILE Lof(MySock) = 0
    WAIT 0.1
  LOOP
  READ #MySock, sBuf, Lof(MySock)
  PRINT sBuf

  CLOSE #MySock

END
'-------------------------------------------------------------

PUBLIC SUB Button2_Click()


DIM sOutput AS String
EXEC ["python", "psock.py"] TO sOutput

PRINT sOutput
END

'>>>>>>>>>>>>>  psock.py  <<<<<<<<<<<<<<<<<<<<<
'import socket
'
's = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
's.connect("/var/run/gtm2")
'
'data = s.recv(1024)
's.close()
'PRINT 'recvd ', repr(data)
'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

**********************************************************************************************************************

This calls a script via inetd that just sends a message and terminates

The script is verified as working using psock.py ( code above )

When run va Button2 works as expected

When run via Button1 give errors thus

status15
 Status = -6
Error <>7 -6
WARNING: circular references detected
FMain (1)
Mutex destroy failure: Device or resource busy
WARNING: 10 allocation(s) non freed.

If tcp socket is used to connect to script then Button1 code works OK

Can anybody help

Thanks

Chris Dunworth

BTW superb product, keep up the good work



More information about the User mailing list