CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: problem

  1. #1
    Join Date
    May 2012
    Posts
    14

    problem

    #!/usr/bin/python
    import socket

    sock = socket.socket(socket.AF_INET,socket.SOCK_RAW,socket.IPPROTO_TCP)
    while 1:
    print sock.recvfrom(65565)
    sock.close()

    i run that prog but why its gives error (10022 invalid argument)on recvfrom(65565) i also changed it like recvfrom(1024) but its gives error i run it on windows xp sp2i also tried bind with it but that type its give error on bind like
    #!/usr/bin/python
    import socket

    sock = socket.socket(socket.AF_INET,socket.SOCK_RAW,socket.IPPROTO_TCP)
    host = "192.168.1.2"
    port = 0
    sock.bind((host,port))
    while 1:
    print sock.recvfrom(65565)
    sock.close()
    that time its gives error (10022 invalid argument)on bind tell why its coming

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: problem

    Port numbers are just 16 bits so 65565 is not valid.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    May 2012
    Posts
    14

    Re: problem

    65565 is buffer size

  4. #4
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: problem

    Oh, I assumed it was the port since it was close to 16 bit max value. Sorry.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured