11 years, 6 months ago.

python

From the TCP Echo Examle on the mbed website i copied some code, it also mentioned: "You can test the above server running on your mbed, with the following Python script running on your PC:"

I downloaded the python program but when i start python.exe there is a ms-dos look a like window opening and i can not type such a text in the command?

Anybody knows this program??

The following code is the code to be put in python script.

import socket
 
ECHO_SERVER_ADDRESS = "10.2.131.195"
ECHO_PORT = 7
 
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
s.connect((ECHO_SERVER_ADDRESS, ECHO_PORT))
 
s.sendall('Hello, world')
data = s.recv(1024)
s.close()
print 'Received', repr(data)

thnx in advance

1 Answer

11 years, 6 months ago.

You should be able to save that code into a file making sure to make the filename ends with ".py".

Then you should be able to run it by double clicking on the file.

Alternatively you can use Python's IDLE which I believe is installed with python in the Windows distribution.

Accepted Answer