faqts : Computers : Programming : Languages : Python : Common Problems

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 13 people (85%) answered Yes
Recently 3 of 3 people (100%) answered Yes

Entry

Is it possible for a program to bind to a socket when that socket is already bound to another application to monitor i/o?

May 17th, 2000 02:12
unknown unknown, Oleg Broytmann, Warren Postma


It is impossible.

But, why not write a Python program to be a server on port 25, which 
just opens another port and relays the data. Then reconfigure your 
original server (say SMTP) to go somewhere else, like 8881, and your 
Python program can redirect (with a small delay) as well as dumping out 
what comes in?

You can't leave your server app on the port and let anyone else use it, 
but you can fake it with a relay+dumping program. You could also (on 
Windows NT/2000 but not on Unix) "hook" the Winsock DLL functions. For 
more on how to build DLL hooks, go to the Microsoft Research web page 
and look for "DLL hooks".