[Gmsh] feature request: gmsh reads input from TCP port

Christophe Geuzaine cag32 at case.edu
Thu Mar 23 03:56:22 CET 2006


Al Danial wrote:
>>> On the Linux side once again I did "cat cone.geo | nc 192.168.1.103 44122"
>>> and this caused gmsh on Windows to crash.  I figured I'd better go
>> It shouldn't crash, but it's normal that it doesn't work: you cannot
>> just send data on the socket--you have to follow Gmsh's solver protocol.
>> (That's what GmshClient.h is there for. Basically, the data is sent with
>> headers explaining the nature of what is sent next.)
> 
> OK, that explains a lot.
> 
> My naive view of a solution to accepting inputs over TCP was more along
> the lines of how gmsh currenlty reads commands from a file.  The gmsh
> file reader must do something like this:
> 
>   open the file
>   while not end-of-file {
>     read a line of input
>     process the line
>   }
>   close the file
> 
> A TCP reader could work the same way as the file reader:
> 
>   open the socket
>   while not disconnected {
>     read a line of input
>     process the line
>   }
>   close the socket
> 
> As long as the data coming over the socket looks line lines of text
> there should be no difference between file input and socket input.
> Of course pseudocode is easy to rattle off and I'm probably overlooking
> complicating factors.

Hi Al - If we do it like this we would limit ourselves to single line
commands... or we would need to re-establish a connection for each
command in order to know when to process it? Also, the goal (eventually)
would be to transmit binary data directly on the socket, so we really
need some kind of protocol to announce what the data is.

I've played around with the code a bit more today, and it seems to work
pretty reliably between my Linux box and my Mac (there was a byte
ordering issue when the client and the solver ran on machines with
different byte orderings, but that's now fixed in cvs). I still have to
test with a Windows machine, though.

Also, I've made the "interactive.cpp" test program a bit easier to use.
You can now do stuff like this:

1) On the graphical machine (say "mypc"), launch Gmsh with
"localhost:44122" as the socket name and "Always listen to incoming
connection requests" set to 1

2) On the machine, just run "interactive.exe mypc:44122". You can then
type any commands at the prompt (try e.g. "argh", which I've
pre-programmed to send a 1Mb post-processing view.)

Best,

Christophe



> 
>>> I then tried the "cat cone.geo | nc ..." again but this time gmsh just
>>> ignored it.  The gmsh message window said
>>>     Warning : Failed to receive body on socket: aborting
>>>     Info    : Client disconnected: starting new connection
>> That's pretty good actually: it means that it received a header
>> (probably just lucky to get a number that is in the protocol), but
>> didn't get the associated data.
>>
>>> For some reason I was initially able to send something between Linux
>>> and gmsh on Windows but it isn't repeatable; all subsequent attempts
>>> failed.   Next I will try going from Windows to Linux, will post my
>>> findings.   -- Al
>>>
>> Sounds good. I've only had a chance to test all this stuff on "single"
>> machines, so your tests will be useful.
> 
> Naturally the Windows to Linux method failed too as I tried the same
> trick of sending the contents of a geo file through a socket without
> specifying any protocol.            -- Al
> 


-- 
Christophe Geuzaine
Assistant Professor, Case Western Reserve University, Mathematics
http://www.case.edu/artsci/math/geuzaine