473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Socket Programming - Question

I am relatively new to Python, and wanted to see if this is even
possible, and if so how to go about implementing it. What I'm looking
to do is create a client/server application that does the following:

1) System2 listens on port > 1023
2) System1 connects to System2 and sends traffic to it - based on the
traffic it receives (i.e. a special string), System2 executes
command-line commands and returns the output to System1.

An example of what I am looking to use this for is for remote virus
scanning. So System2 listens, System1 connects and sends it the
traffic to start the scan, then System1 returns either what would be
listed in the Command Prompt window, or possibly the contents of the
logfile.

Any help would be greatly appreciated!

Doug

Feb 11 '06 #1
6 1381
du********@hotmail.com wrote:
An example of what I am looking to use this for is for remote virus
scanning. So System2 listens, System1 connects and sends it the


Just found this through OSNews:
http://rpyc.sourceforge.net/

It actually seems to be a perfect fit for your job.

Lorenzo

Feb 11 '06 #2
On 2006-02-11, du********@hotmail.com <du********@hotmail.com> wrote:
I am relatively new to Python, and wanted to see if this is
even possible, and if so how to go about implementing it.
What I'm looking to do is create a client/server application
that does the following:

1) System2 listens on port > 1023
2) System1 connects to System2 and sends traffic to it - based on the
traffic it receives (i.e. a special string), System2 executes
command-line commands and returns the output to System1.


Sure. Just use os.popen() or one of it's relatives to execute
the program:

http://www.python.org/doc/current/li...#os-newstreams

--
Grant Edwards grante Yow! I'm not available
at for comment...
visi.com
Feb 11 '06 #3
D
Thanks! Now, I'm a bit confused as to exactly how it works - will it
display the output of what it executes on the target system? I would
like to create a window in Tktinker to where a user can select options
(such as run scan on remote system) - it would then run the
command-line based scan and return the output. Does this sound like
something it would do? Thanks again :)

Feb 11 '06 #4
D
I've used os.popen() before, but if I execute it on a remote system how
could I get the output back to the requesting machine?

Feb 11 '06 #5
"du********@hotmail.com" <du********@hotmail.com> writes:
I am relatively new to Python, and wanted to see if this is even
possible, and if so how to go about implementing it. What I'm looking
to do is create a client/server application that does the following:

1) System2 listens on port > 1023
2) System1 connects to System2 and sends traffic to it - based on the
traffic it receives (i.e. a special string), System2 executes
command-line commands and returns the output to System1.


You're asking how to write a TCP server in general. You might look at
the SocketServer module in the standard library, which gives a
reasonable framework for that kind of server. However, its
documentation is not very good. Alex Martelli's "Python Cookbook" may
have some better examples.

If you want your server to be able to handle multiple client sessions
simultaneously, use SocketServer.ThreadingMixin (for multiple threads)
or SocketServer.ForkingMixin (multiple processes). Beware that this
stuff is not easy for beginners, unless you've had experience writing
servers in other languages (maybe Java).

There's another issue too, especially if your app is a virus scanner:
you have to think very hard about what happens if a malicious client
connects to your server (a virus scanning app is an unusually juicy
target for such attacks). It's extremely easy to leave security holes
open (the viruses themselves typically exploit such holes in Windows)
so you have to develop a paranoid attitude about what kinds of things
the attacker can try and how you can defend. Using Python puts you
one step ahead of Windows, since you're mostly immune to buffer
overflow bugs, a very common vulnerability. But it's still an area
full of hazards and not so good for beginners.

This is good bedtime reading: http://www.dwheeler.com/secure-programs/
Feb 11 '06 #6
On 2006-02-11, D <du********@hotmail.com> wrote:
I've used os.popen() before, but if I execute it on a remote
system how could I get the output back to the requesting
machine?


Write it to the socket?

--
Grant Edwards grante Yow! Where does it go when
at you flush?
visi.com
Feb 11 '06 #7

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

Similar topics

2
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...
2
by: dream machine | last post by:
Hi all , with BegeinReceive I can build async method of Socket Class that Receive the data from the Socket Client . My question is , if I have this code that create 3 Receive Async Call : ...
1
by: John Sheppard | last post by:
Thanks to everyone that responded to my previous Socket Programming question. Now I have run into some behavior that I don't quite understand. Programming environment. VS.NET 2003, C#, Windows...
5
by: mscirri | last post by:
The code below is what I am using to asynchronously get data from a PocketPC device. The data comes in fine in blocks of 1024 bytes but even when I send no data from the PocketPC constant blocks of...
5
by: Justin Creasy | last post by:
If this is the wrong group for this posting please let me know and I'll move it. I have an application that has an ArrayList of sockets to clients. For standard one-to-one messages my...
2
by: djc | last post by:
I read a network programming book (based on framework 1.1) which indicated that you should 'never' use the RecieveTimeout or the SendTimeout 'socket options' on TCP sockets or you may loose data. I...
14
by: =?Utf-8?B?TWlrZVo=?= | last post by:
I have a sync socket application. The client is blocked with Socket.Receive(...) in a thread, another thread calls Socket.Close(). This unblock the blocked thread. But the socket server is still...
3
by: Stuart | last post by:
I am in the process of teaching myself socket programming. I am "playing around" with some simple echo server-client programs for m the book TCP/IP Sockets in C. The Server program is: ...
1
by: =?Utf-8?B?UmFqbmk=?= | last post by:
Dear Sir/Mam, I have written a server code using the Windows Socket API's. Wherein I have created the socket and bound it to a particular IP address and port number. Later I have made the socket...
4
by: danomano | last post by:
The code below works fine. As of now I just set the buffer length real big and all is good. However, I hate the impreciseness of that. So my question in general is how do I know what length to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...

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.