cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
test_python_socket.py
Go to the documentation of this file.
1 #
2 # Hello World client in Python
3 # Connects REQ socket to tcp://localhost:5555
4 # Sends "Hello" to server, expects "World" back
5 #
6 
7 import socket
8 
9 msgFromClient = "HelloUDPServer"
10 bytesToSend = str.encode(msgFromClient)
11 serverAddressPort = ("127.0.0.1", 2718)
12 bufferSize = 1024
13 
14 # Create a UDP socket at client side
15 UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
16 
17 # Send to server using created UDP socket
18 UDPClientSocket.sendto(bytesToSend, serverAddressPort)
19 
20 msgFromServer = UDPClientSocket.recvfrom(bufferSize)
21 
22 msg = "Message from Server {}".format(msgFromServer[0])
23 
24 print(msg)