473,800 Members | 2,227 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Newbie: Keep TCP socket open

Hi Folks,
I am newbie to Python, but have successfully created a simple client and
server setup, I have one issue though.

I am trying to test a box by sending many TCP conns (WHILE loop) but not
closing them with a FIN/RST. However, no matter what i do, i cannot get the
loop to stop sending FIN from the client.

Any clues?

Here is my current script

#!/usr/bin/python

import socket,sys
from numpy import *
num1=0

while (num1<=10) :

s = socket.socket(s ocket.AF_INET, socket.SOCK_STR EAM)
s.settimeout(10 .0)
s.connect(("10. 1.1.69", 50008)) # SMTP
print s.recv(1024) + '\n',
num1=num1+1
#s.close()
sys.exit(1)
Jun 27 '08
13 9004
In article <ia************ *************** ***@pipex.net>,
"Alan Wright" <al*********@vo lubill.comwrote :
Thanks Roy

Any ideas how to code this child process stuff, as I said I am newbie and
not from a coding background
The easiest thing would be to use os.system(). If you wanted to spawn 10
child processes, you could do:

import os
for i in range(10):
os.system ("./child.py &")

and then have child.py be a script that creates 1000 TCP connections.

Keep in mind that one man's stress test is another man's denial of service
attack. If there are any firewalls between you and your target, they may
restrict the number of connections you get to make (or the rate at which
they're created). You may also get a polite phone call from your local IT
people asking enquiring about your activities.
Jun 27 '08 #11
You must have something in your IPtables

I needed to put a rule in to drop these unwanted RST from getting back out.

All fixed now

Thanks for the advice

Alan

"Alan Wright" <al*********@vo lubill.comwrote in message
news:ia******** *************** *******@pipex.n et...
Same on FC8, sends RST after it sees SYN/ACK

"Ghirai" <gh****@ghirai. comwrote in message
news:ma******** *************** *************** *@python.org...
>On Mon, 19 May 2008 23:50:50 +0100
"Alan Wright" <al*********@vo lubill.comwrote :
>>Ghirai,
Scapy does the same, only it sends RST and not FIN, so still no help

send(IP(dst="10 .1.1.2")/TCP(dport=50000 ,flags="S"))

Only have windows at the moment sadly.

Alan

Are you sure there's no firewall or something else between you and the
remote host?

Because i just tried that command with scapy and it didn't send any other
packets
except what it was told (1 packet with SYN flag set).

I haven't tried on windows though.

--
Regards,
Ghirai.


Jun 27 '08 #12
Thanks Roy, will give it a go.

infact there is no need for any IT phone calls, I am the owner of this
network

Very simple [bunch of clients]----[box under test]----[bunch of servers]

Now i should be able to hammer them ;)

Alan

"Roy Smith" <ro*@panix.comw rote in message
news:ro******** *************** @70-1-84-166.area1.spcsd ns.net...
In article <ia************ *************** ***@pipex.net>,
"Alan Wright" <al*********@vo lubill.comwrote :
>Thanks Roy

Any ideas how to code this child process stuff, as I said I am newbie and
not from a coding background

The easiest thing would be to use os.system(). If you wanted to spawn 10
child processes, you could do:

import os
for i in range(10):
os.system ("./child.py &")

and then have child.py be a script that creates 1000 TCP connections.

Keep in mind that one man's stress test is another man's denial of service
attack. If there are any firewalls between you and your target, they may
restrict the number of connections you get to make (or the rate at which
they're created). You may also get a polite phone call from your local IT
people asking enquiring about your activities.

Jun 27 '08 #13
In article <3K************ *********@pipex .net>,
"Alan Wright" <al*********@vo lubill.comwrote :
infact there is no need for any IT phone calls, I am the owner of this
network
That's the best way to do it :-)
Jun 27 '08 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3371
by: Jane Austine | last post by:
Running Python 2.3 on Win XP It seems like socket is working interdependently with subprocesses of the process which created socket. ------------------------------------ #the server side >>> import socket >>> s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) >>> s.bind(('localhost',9000))
3
9115
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on the client machine to close per my network app the computer fills up w/ thousands of these :0 TCP foobox:8888 localhost:2188 TIME_WAIT :0 TCP foobox:8888 localhost:2189 TIME_WAIT :0 TCP foobox:8888 localhost:2190 TIME_WAIT
2
13746
by: Jean-Philippe Guyon | last post by:
Hello, I am trying to compile a class that uses socket using the Visual C++ ..NET compiler. I get the following error: ------ Build started: Project: infCommon, Configuration: Release Win32 ------ Compiling... cl : Command line warning D4029 : optimization is not available in the
4
6399
by: zelzel.zsu | last post by:
I wrote two simple socket program. one for sending a file and the other for receiving the file. but when I run it, a curious thing happened. The received file was samller that the sent file. $ cat receivefile.py #!/usr/local/bin/python # -*- coding: utf-8 -*- import socket
9
11350
by: AA | last post by:
This is making me crazy!! Please, if some body can help me. I'm testing a ver simple socket client. In my test I just open and close a connection (in a loop) to my local IIS server (port 80) using System.Net.Sockets;
1
2427
by: Techsol | last post by:
Hi, I have synchronous communications between a server and client. To save bandwith the connection must persist. So the socket must stay open and only be re-opened in case of communications failure. To simulate failure, the server disconnects the socket. However, the client socket parameter shows an open socket: socket.connected is true, socket. Active is true, socket.poll(1,selectRead) is true. When checking the MS class documentation, it is...
13
2650
by: coloradowebdev | last post by:
i am working on basically a proxy server that handles requests via remoting from clients and executes transactions against a third-party server via TCP. the remoting site works like a champ. my problem is executing the transactions against the remote server and returning the response to the remoting client. i can open the socket fine and, if i am executing one transaction at a time, everything works great. it's when my proxy server...
0
2806
by: Jaap Spies | last post by:
Hi, Running Fedora Core 4: Python 2.4.3 and Python 2.4.1. I'm getting: IOError: (2, 'No such file or directory') all the time. Trying to track down this problem: Python 2.4.1 (#1, May 16 2005, 15:19:29)
4
16171
by: O.B. | last post by:
I have a socket configured as TCP and running as a listener. When I close socket, it doesn't always free up the port immediately. Even when no connections have been made to it. So when I open the socket again, the bind fails because the port is still in use. When I execute the code in "debug" mode, the problem never occurs. When I execute the same code in release mode, the problem appears about 20% of the time. Here's the code:
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9085
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7576
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2945
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.