Author giampaolo.rodola
Recipients giampaolo.rodola
Date 2008-07-04.02:18:00
SpamBayes Score 3.82089e-05
Marked as misclassified No
Message-id <>
When the SO_OOBINLINE option is used against a socket, out-of-band data
should be placed in the normal data input stream as it is received.
In fact this is what happens on Windows and Linux by using the script below.
On FreeBSD this does not happen. select instead of returning a
"readable" file descriptor returns an "exceptional" file descriptor. 
Later, when we try to read some data from the socket, the following
exception is raised:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/local/lib/python2.5/", line 460, in __bootstrap
  File "/usr/local/lib/python2.5/", line 440, in run
    self.__target(*self.__args, **self.__kwargs)
  File "", line 14, in server
    data = conn.recv(1024, socket.MSG_OOB)
error: (22, 'Invalid argument')

--- code ---

import socket, select, threading, time, os

def server():
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    s.bind(('', 1024))
    conn, addr = s.accept()
    conn.setsockopt(socket.SOL_SOCKET, socket.SO_OOBINLINE, 1)
    while 1:
        r, w, e =[conn], [conn], [conn], 0.01)
        if r:
            # the socket is supposed to be in the "readable" list
            data = conn.recv(1024)
            print "read -> " + data
        if e:
            # ...but not in the "exception" list
            data = conn.recv(1024, socket.MSG_OOB)
            print "expt -> " + data

s = socket.socket()
s.connect(('', 1024))
s.sendall('x', socket.MSG_OOB)

--- /code ---
Date User Action Args
2008-07-04 02:18:01giampaolo.rodolasetspambayes_score: 3.82089e-05 -> 3.82089e-05
recipients: + giampaolo.rodola
2008-07-04 02:18:01giampaolo.rodolasetspambayes_score: 3.82089e-05 -> 3.82089e-05
messageid: <>
2008-07-04 02:18:00giampaolo.rodolalinkissue3278 messages
2008-07-04 02:18:00giampaolo.rodolacreate