en el sock tcp/udp el buf que sirve es hasta 1500 que es el tamaño maximo del paquete IP por tanto aunque pongan un tamaño mayor dé bufer no Creo qué sirva puesto que los paquetes IP no siempre llegan en todas las ocasiones consecutivos y menos en udp. Y el bufer siempre guarda datos consecutivos.
From : Diego Uribe Gamez
To : La lista de python en castellano;
Subject : Re: [Python-es] UDPSock.recvfrom(buf) ??????? (buf) ???
 
Que determina el tamaño del paquete, si yo envió un dato de un computador a otro que tanto se abre buff para recibir el tirón completo.

Sobre la información de la documentación solo encontré esto buffer allocation on receive operations is automatic, and buffer length is implicit on send operations. y el ejemplo con buffer para mi caso al final del documento:

# receive a package
print s.recvfrom(65565)

import socket

# the public network interface
HOST = socket.gethostbyname(socket.gethostname())

# create a raw socket and bind it to the public interface
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP)
s.bind((HOST, 0))

# Include IP headers
s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1)

# receive all packages
s.ioctl(socket.SIO_RCVALL, socket..RCVALL_ON)

# receive a package
print s.recvfrom(65565)

# disabled promiscuous mode
s.ioctl(socket.SIO_RCVALL, socket..RCVALL_OFF)

Running an example several times with too small delay between executions, could lead to this error:


socket.error: [Errno 98] Address already in use

This is because the previous execution has left the socket in a TIME_WAIT state, and can’t be immediately reused.

There is a socket flag to set, in order to prevent this, socket.SO_REUSEADDR:


s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((HOST, PORT))

the SO_REUSEADDR flag tells the kernel to reuse a local socket in TIME_WAIT state, without waiting for its natural timeout to expire.


El 7 de junio de 2012 08:45, mauricio rodriguez <[email protected]> escribió:
es la cantidad de datos que recibe o envía de un tirón ... no la totalidad del trafico sino el tamaño del paquete

2012/6/7 Diego Uribe Gamez <[email protected]>
Estoy mirando una conexión por Soket y no logro entender que hace el buf? que es lo que cambia? el numero que se le asigna es que?


host = "localhost"
port 
= 21567
buf 
= 1024
data 
= ''
addr 
= (host, port)

UDPSock = socket(AF_INET, SOCK_DGRAM)


while (1):
 
data, addr = UDPSock.recvfrom(buf)

--
 Diego Alonso Uribe Gamez

 

Desarrollador web

Twitter: @DiegoUG

Google+: http://gplus.to/diegoug



 

 



_______________________________________________
Python-es mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/



_______________________________________________
Python-es mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/




--
 Diego Alonso Uribe Gamez

 

Desarrollador web

Twitter: @DiegoUG

Google+: http://gplus.to/diegoug



 

 


_______________________________________________
Python-es mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-es
FAQ: http://python-es-faq.wikidot.com/

Responder a