cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Vertigo42
Level I

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

 

 

 

 

1 REPLY 1
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