- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Connecting and listen to a socket
Hi, I'm Jmp 17 user.
I have a python script that is a server that keep sending short messages every 3 sec.
I'm trying to connect and receive these numbers in jmp.
I used this HTTP Request example as reference, but the callbackfn never get called.
callbackfn = function( {x},
write ("Message Recieved");
);
//Create a socket
con = Socket();
//Use a specific port on this computer
con << Bind( "localhost", "8081" );
//Tell this socket to be ready for other sockets to connect to it
Write( "\!nlistening on ", (con << getSockName)[3]);
con << Listen();
//When something connects to this socket, call a function to handle
//the connection. Accept connections for the next 5 minutes.
con << Accept(callbackfn, 30000);
The Accept returns {"Accept" , "ok"}, but the callbackfn is never called.
I wrote different python client script that shows what I want to do and it works without any problem.
something like this -
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: # Connect to the server client_socket.connect((host, port)) print(f"Connected to {host}:{port}") while True: # Receive data from the server data = client_socket.recv(1024) if not data: break # Print received data print(f"Received: {data.decode()}")
any idea why I can't get it to work on JMP? I can't find any documentation execpt the example above.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Connecting and listen to a socket
Scripting Index does have more documentation
and there is also some in Scripting Guide in JMP Help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Connecting and listen to a socket
Thanks for your reply.
I already checked the scripting Guide, the scripting index and the samples folder, I coudn't find what I'm looking for.
I'm trying to find a way to get a single number from a server each time it send it, and for now just print it but I don't want to block my JMP app during the waiting. when this will work I'll use this number to update a graph.
I couldn't find how to start a new thread like it is usually done, any other source/direction will be helpfull
Thanks