socket problem?

Donn Cave donn at oz.net
Tue Sep 12 07:27:22 CEST 2000


Quoth Zajcev Evgeny <lg at localhost.rgz.ru>:

| want to use socket.sendto method to send data via TCP
| and for example send SYN packet to some host

| >>> import socket
| >>> a = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_TCP)
| >>> a.sendto('E\020\000,\001\360@\000@\006t\223\325\270\214d\325\270\214c\0179\000\025X\352\247g\000\000\000`\002\000\004M\000\002\004[@\000', ('mail.rgz.ru', 0))
| Traceback (most recent call last):
|   File "<stdin>", line 1, in ?
| socket.error: (49, "Can't assign requested address")
| >>> 
|
| i'm fall in out, it doesnt work!
| i try with other socket types and protos ==> work perfect but TCP
|
| explain me please where i'm misataken or it is long discovered bug?

I could be wrong, but I believe a SOCK_STREAM has to be connected.  Like,

 a = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
 a.connect(('mail.rgz.ru', 7010))
 a.send('E...')
 a.close()

If I understand right, you may have already tried SOCK_DGRAM and
found that to work - that's where I would use sendto() and recvfrom().

	Donn Cave, donn at oz.net



More information about the Python-list mailing list