log incoming ip/porrt connections

D

D. Xenakis

Hi there. I have a script-service running on a remote server, listening on a specific port. What i need here is to make this also maintain a log file of ALL incoming connections.

Could someone suggest to me a simple codefunction example to implement that on my main running service?

THX!!
 
I

Irmen de Jong

Hi there. I have a script-service running on a remote server, listening on a specific port. What i need here is to make this also maintain a log file of ALL incoming connections.

Could someone suggest to me a simple codefunction example to implement that on my main running service?

THX!!

One approach could be simply to log the client socket's peername to a logfile, something
like this:

import logging
log=logging.getLogger("connections")

....
if <<new connection>>:
clientsocket = ...
log.debug("new connection from "+clientsocket.getpeername())
...



Irmen
 
D

D. Xenakis

This monitors also ip/port of incoming udp packets?
Or just tcp after a connection has been enstablished?
If i dont make any sense, plz correct me. Not much experience with networking here :)
 
D

Dennis Lee Bieber

This monitors also ip/port of incoming udp packets?
Or just tcp after a connection has been enstablished?
If i dont make any sense, plz correct me. Not much experience with networking here :)

It begins to sound like you want some of the capability of Wireshark...
In that case you'll want to obtain the PCAP libraries (included with
Wireshark on Windows) AND the PCAP Python module. Warning, you may need to
run in Admin mode to be able to snoop the NIC...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top