大家好,我是 Jmp 17 用戶。
我有一個 python 腳本,它是一個每 3 秒發送簡訊的伺服器。
我正在嘗試在 jmp 中連接並接收這些數字。
我使用此HTTP 請求範例作為參考,但回調函數從未被呼叫。
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);
Accept 傳回 {"Accept" , "ok"},但回呼函數永遠不會被呼叫。
我編寫了不同的 python 客戶端腳本來顯示我想要做什麼,並且它可以正常工作。
像這樣的東西-
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()}")
知道為什麼我無法讓它在 JMP 上運行嗎?除了上面的範例之外,我找不到任何文件。
謝謝
感謝您的回覆。
我已經檢查了腳本指南、腳本索引和範例資料夾,但找不到我要找的內容。
我正在嘗試找到一種方法,以便在每次發送伺服器時從伺服器獲取單個數字,現在只需列印它,但我不想在等待期間阻止我的 JMP 應用程式。當它起作用時,我將使用這個數字來更新圖表。
我找不到如何像通常那樣啟動新線程,任何其他來源/方向都會有幫助
謝謝