cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
View Original Published Thread

Connecting and listen to a socket

Vertigo42
Level I

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

 

 

 

 

2 REPLIES 2
jthi
Super User


Re: Connecting and listen to a socket

Scripting Index does have more documentation

jthi_0-1734956589663.png

and there is also some in Scripting Guide in JMP Help

-Jarmo
Vertigo42
Level I


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