473,395 Members | 1,464 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,395 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 2631
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.