Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCP/UDP Port -- Socket

Status
Not open for further replies.

Rockman75

Technical User
Nov 2, 2002
17
US
Hi, all

Question. Im wondering if I am able to close any current unused TCP/UDP port opened by another processes.

I mean, I do not want to shut down the ports with Firewall soft, but I`d rather write a program or script to do the work if I can.

So, If I write a program with VC++6.0, Can i just simply use a function, createsocket() and closesocket()? If thats the case, how do I bind the socket and port. See what I maen? Sorry I cant explain well, but if you see what Im tryin to find, ping me pls....thanx
 
hi, sockets are a sort of file pointer:
how can you close from program2 an handle open
by program1 ?

By program, you can close sockets opened by your program:
to release other, you have to kill them, or better
avoid that they starts at boot.

bye
 
You could write an application that checks what processes currently have ports open, and kill those applications. Or you can write a TCP/IP shim and just capture the data as it attempts to come in or out (this is what the firewalls do).

You might be able to install PERL and use Net::RawIP to capture data moving both directions. I've used it as a trigger before, but never tried to have it intercept the data without passing it up the stack.

pansophic
 
HI, slightly off topic here,

You mentioned a tcp/ip shim to to capture data on its way thru.....

do you know how this is done, i need to make an app that can do this, to monitor only one particular port, and monitor/capture data coming in on it..

Any assistance would be greatly appreciated.. In a windows environment would be preferable, as the end user isnt linux aware....

Thanks

Mattb
 
I have no idea how it is done, but take a look at libpcap. It is a packet capture library that has been ported to Windows, and source is available.

The VPN clients that are installed on Windows make use of a shim, that is how they can capture and then encrypt and decrypt data as it passes through the IP stack.

The libpcap is simply packet capture, but I believe that the concepts are the same. As long as you don't need to modify the data as it passes through, you can probably use tcpdump (also ported to windows) to capture the data in a passive mode.


Good luck!

pansophic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top