accesing socket at a lower level?

Cedric Adjih adjih at crepuscule.com
Fri May 19 12:36:00 EDT 2000


Z 3 Penguin <z3penguin at penguinpowered.com> wrote:
> Cedric Adjih wrote in message <8g0ool$q09$3 at ites.inria.fr>...
>>Z 3 Penguin <z3penguin at penguinpowered.com> wrote:
>>> I am working on writing python code to access the AIM servers.  i have
> been
>>> looking at what my code sends out, and using something like
>>
>>> from socket import +ACo-
>>> s+AD0-socket(AF+AF8-INET,SOCK+AF8-STREAM)
>>> s.send(whateverstring)
>>
>>  Assuming the missing "s.connect(hostname, port)"
>>(or "s.connect((hostname, port))"), your code looks correct.

> Oops.
>>
>>> tacks on some extra bytes at the beggining.  this confuses the AIM
> servers.
>>> Any ideas? (Note: I am not good with C and am against having to write
> this
>>> in C)
>>
>>Hmm... What told you there were some extra bytes at the beginning?
> TCPDump Log.

  That's a silly question, but did you take into account the
IP headers and TCP headers (with possible options) ? Now some
extra bytes _at the end_ would be ok when padding packets to fit 
Ethernet minimum size.


>>
>>Are you sure:
>>- AIM servers use TCP?
> Yes
>>- Python client is the problem?
> Yes, because other AIM clients work fine.
>>- Python socket C code is properly working?
> Yeah, tryed it under both 1.5.2 (latest debian package) and 1.6a2 (tarball)
>>  (maybe try test_socket.py in somewhere in the library of Python
>>  -- /usr/lib/python1.5/test/test_socket.py or whatever -- or try
>>  one of the socker examples).

> Also, tryed

> from socket import *
> s=socket(AF_INET,SOCKET_RAW
> Traceback
> socket.error: (93, 'Protocol not supported')

SOCKET_RAW is low level, and should be used only to send raw packets.
For UDP it would have been SOCK_DGRAM. But this is not the culprit


I don't know what problem you have, but if it is Python, it looks
tricky. Here an example program that works perfectly on my machine
----------------------------------------
from socket import *

s=socket(AF_INET,SOCK_STREAM)
echoTcpPort=7
s.connect(("localhost", echoTcpPort))
s.send("hello")
print ">>>%s<<<" % s.recv(1024)
----------------------------------------
(printing ">>>hello<<<", with Debian 2.1 and python 1.5.2 on x86)

-- Cedric 




More information about the Python-list mailing list