Hi All,

I found the problem.

It seems   MySock.Connect("/var/run/gtm2")
does require a port parameter

using

MySock.Connect("/var/run/gtm2", Net.local)

socket opens and works corectly.
I found this info by browsing through cSocket.c source code in the
bg.netcomponent.
 /********************************************************************
 Port to connect to. Can be 'Net.Local' for Unix sockets, or
 1-65535 for TCP sockets
 ********************************************************************/
BEGIN_PROPERTY(CSOCKET_Port)

    if (READ_PROPERTY)
    {
        GB.ReturnInteger(THIS->iUsePort);
        return;
    }

    if (THIS->iStatus>0)
    {
        GB.Error("Port property can not be changed while working");
        return;
    }
    if (VPROP(GB_INTEGER)<0)    { THIS->iUsePort=0; return; }
    if (VPROP(GB_INTEGER)>65535)     { THIS->iUsePort=65535; return; }
    THIS->iUsePort=VPROP(GB_INTEGER);


END_PROPERTY
/*********************************************************************



Charlie,
 using a version that dates from Sep 2009 is hardly 'very old'

Regards,

Chris Dunworth




Date: Fri, 02 Apr 2010 23:45:11 +0200
From: Charlie Reinl <karl.re...@fen-net.de>
Subject: Re: [Gambas-user] UNIX SOCKETS
To: mailing list for gambas users <gambas-user@lists.sourceforge.net>
Message-ID: <1270244711.8001.2.camel@
localhost>
Content-Type: text/plain

Am Freitag, den 02.04.2010, 22:34 +0100 schrieb Chris Dunworth:
> 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------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 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

Salut,

as you use a very old version, please look at

http://gambas.sourceforge.net/en/changelog2.html

if a new version would not be better to use!


--
Amicalement
Charlie
------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to