473,810 Members | 3,102 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help sending data over a socket

WhiteRider
37 New Member
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 2651
WhiteRider
37 New Member
Does no-one have any knowledge on Python Socket programming that they could share with me?
Oct 29 '07 #2
bartonc
6,596 Recognized Expert Expert
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
WhiteRider
37 New Member
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
6986
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 questions about the implementation of Python sockets. (both methods use blocking sockets) Method 1: Calls socket.sendall(data) for each device in sequence, all in a single thread.
1
3801
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 after i send data into it? I simply want to open socket, send data, close socket and have the server just handle one client thread to recieve connection, recieve data, and close socket
8
5484
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 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
3
4439
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 is that when I recognize FD_ISSET from stdin, I am stuck there. The loop does not return me to select() between stdin and listening socket. Similarly, when I accept a client, the loop does not return me to select between stdin and listeing...
3
4641
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 and then fires a datareceived event. Within the waitingloop there is a timeout function, but I want the the 'last-time-socket-used' variable set when the socket is finished sending. When I send by System.Net.Sockets.Socket.Send(buffer()) (<--this...
4
8206
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 TcpClient, NetworkStream and StreamWriter classes. but with low level socket it doesn't work (When using the Socket class Send method).
3
4318
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 receiver is running within Process1. If I move the receiver into Process2 then its fast. Please can someone explain.
6
2988
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 them. to be more clear we process this purpose we serve this to the student in the university. how?? student will send a message that contains his name,id and request by format the server want such as zaina-20024008-grade. the grade is the request...
2
3055
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 (http://msdn.microsoft.com/en-us/library/ms740148(VS.85).aspx) subsequent calls of sendto function should result in returning WSAECONNRESET error code caused by returning ICMP destination unreachable message. My problem is that I do not see such effect, the sendto always...
0
9722
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10644
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
10393
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
10124
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9200
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
7664
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
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
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...
1
4334
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

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.