473,287 Members | 3,286 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,287 software developers and data experts.

Help sending data over a socket

WhiteRider
I have some basic knowledge of socket programming in Python. Up to now all I have been able to do when establishing a socket is sending a string to a client, what I would like to know is what else can be sent? For example could a program be tunnelled through from the host to the client - like the way netcat allows programs to be executed after a connection is established?

Here is code that only sends a string:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/python
  2. import socket, sys
  3.  
  4. if len(sys.argv) < 3:
  5.     print 'Usage: %s [IP] [port]' % sys.argv[0]
  6.     sys.exit(1)
  7.  
  8. ip = sys.argv[1]
  9. port = int(sys.argv[2])
  10.  
  11. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  12. sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
  13.  
  14.  
  15. sock.bind((ip, port))
  16. sock.listen(1)
  17. print "Waiting for someone."
  18.  
  19. request, client = sock.accept()
  20. print "Received connection from", client
  21. request.send('Some boring text..\n') #<-- can a program be sent instead of this?
  22. request.shutdown(2) 
  23. print "Socket closed."
  24. sock.close() 
  25.  
Oct 22 '07 #1
3 2627
Does no-one have any knowledge on Python Socket programming that they could share with me?
Oct 29 '07 #2
bartonc
6,596 Expert 4TB
Does no-one have any knowledge on Python Socket programming that they could share with me?
The best indication of the amount of action regarding this issue is the first hit on Google for python socket tutorial:Socket Programming HOWTO (1998). But I'll keep digging.
Oct 30 '07 #3
The best indication of the amount of action regarding this issue is the first hit on Google for python socket tutorial:Socket Programming HOWTO (1998). But I'll keep digging.
I've read that HOWTO. Problem is, is that it only tells you how to set-up a socket. I'm comfortable setting up TCP or UDP sockets I just want to branch out and do others things such as send files or as I mentioned in the first post, tunnel things, like a reverse shell or something interesting like that.
Oct 30 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tim Black | last post by:
My application requires sending a large piece (~2MB) of data to several devices on a network via TCP sockets. I have experimented with different methods for doing this and this has raised some...
1
by: Daniel | last post by:
after opening socket, sending data then closing socket 3000 times i get "Only one usage of each socket address" what am i doing wrong? is there some thing else i need to do to free up the socket...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
3
by: Marcia Hon | last post by:
Hi, I am trying to use the select() socket programming command to select between stdin and a connection. Currently, I have a listening stream and stdin that I insert into the fd_set. The problem...
3
by: Robert A. van Ginkel | last post by:
Hello Fellow Developer, I use the System.Net.Sockets to send/receive data (no tcpclient/tcplistener), I made a receivethread in my wrapper, the receivethread loops/sleeps while waiting for data...
4
by: yaron | last post by:
Hi, I have a problem when sending data over TCP socket from c# client to java server. the connection established ok, but i can't send data from c# client to java server. it's work ok with...
3
by: BuddyWork | last post by:
Hello, Could someone please explain why the Socket.Send is slow to send to the same process it sending from. Eg. Process1 calls Socket.Send which sends to the same IP address and port, the...
6
by: zaina | last post by:
hi everybody i am nwebie in this forum but i think it is useful for me and the member are helpful my project is about connecting client with the server to start exchanging messages between...
2
by: =?Utf-8?B?R3JlZ0lJ?= | last post by:
Hi All, I have some problems with sending UDP packets using Winsock. I tried to send some to a closed port, and according to the documentation on Microsoft MSDN site...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.