Python'u kullanarak UDP Yuvaları aracılığıyla bir dizi göndermek mümkün mü? Python 2.5 kullanıyorum ve basit bir dizi göndermeye çalışıyorum ama çalışmıyor. Diziyi başarıyla gönderebilir ancak dizinin bir öğesiyle yazdırmaya çalıştığımda program çöküyor. Verileri bir diziye dönüştürme önlemini aldığımdan hatanın ne olduğundan emin değilim, ancak çalışmıyor. Umarım problemi olabildiğince açık bir şekilde açıkladım. Yardımın için minnettar olurum!Soketler üzerinden diziler gönderme ve alma
# Client program
from socket import *
import numpy
from array import*
# Set the socket parameters
host = "localhost"
port = 21567
buf = 4096
addr = (host,port)
# Create socket
UDPSock = socket(AF_INET,SOCK_DGRAM)
def_msg = "===Enter message to send to server===";
print "\n",def_msg
a = array('i',[1,3,2])
# Send messages
while (1):
data = raw_input('yes or now')
if data!= "yes":
break
else:
if(UDPSock.sendto(a,addr)):
print "Sending message"
# Close socket
UDPSock.close()
# Server program
from socket import *
# Set the socket parameters
host = "localhost"
port = 21567
buf = 4096
addr = (host,port)
# Create socket and bind to address
UDPSock = socket(AF_INET,SOCK_DGRAM)
UDPSock.bind(addr)
# Receive messages
while 1:
data,addr = UDPSock.recvfrom(buf)
L = eval(data)
if not data:
print "Client has exited!"
break
else:
print "\nReceived message '", L[1],"'"
# Close socket
UDPSock.close()
Bu eser, Teşekkürler! – dawnoflife