socket problem?

Zajcev Evgeny lg at localhost.rgz.ru
Tue Sep 12 10:17:35 EDT 2000


Donn Cave <donn at oz.net> writes:

> 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
no it is not what I want
I dont want to use socket allready connected to some host:port
I just need to send 1 tcp/ip packet to someone(i generate this packet according tcp/ip protocols)

i've mistaken in my previos post
i dont assign port that socket use to connect
but when i do it right i got
that when i try to sendto(packet, (host, port)) my packet appended
as tcp data field and all IP and TCP headers generated automaticly
similary to send(packet) in allready connected socket

before it i think that sendto doesnt invoke any ip encoding,
just put it with transmition module.

--zev



More information about the Python-list mailing list