473,624 Members | 2,234 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating a TCP/IP connection on already-networked computers

Let me see if this question even makes sense...I'm reading Core Python
Programming and I jumped ahead to the more specific topics like network
programming. I plan to follow along with the example in that chapter and
create a socket connection between my desktop and laptop.

However, these two computers are already connected on my home network
(using the Windows Network Setup Wizard), so I was wondering if this
will have any effect on what I might try to do with Python. In other
words, if the program I write actually works and allows the two
computers to speak to each other, will that be a result purely of the
program, or will it have anything to do with the fact that they are
already on a home network together? (i.e. there's another variable in play?)

Thanks.
Jun 27 '08 #1
17 5552
On 2008-06-14, John Salerno <jo******@gmail NOSPAM.comwrote :
Let me see if this question even makes sense...I'm reading
Core Python Programming and I jumped ahead to the more
specific topics like network programming. I plan to follow
along with the example in that chapter and create a socket
connection between my desktop and laptop.

However, these two computers are already connected on my home
network (using the Windows Network Setup Wizard), so I was
wondering if this will have any effect on what I might try to
do with Python.
I don't know the example programs you're talking about, but
it's a pretty good bet that the example programs won't work if
the two computers can't reach each other using IP networking.
In other words, if the program I write actually works and
allows the two computers to speak to each other, will that be
a result purely of the program, or will it have anything to do
with the fact that they are already on a home network
together? (i.e. there's another variable in play?)
The two Python programs won't be able to communicate with each
other unless the two computers are already set up on network(s)
that allow the routing of IP packets between the two computers.
I presume that's what the "Network Setup Wizard" did (set up IP
networking), but I don't really do windows (I especially don't
do "Wizards" if I can avoid it).

--
Grant Edwards grante Yow! Alright, you!!
at Imitate a WOUNDED SEAL
visi.com pleading for a PARKING
SPACE!!
Jun 27 '08 #2
John Salerno wrote:
if the program I write actually works and allows the two
computers to speak to each other, will that be a result purely of the
program, or will it have anything to do with the fact that they are
already on a home network together?
Here are the two programs. Server first, then client. They work, which
in itself amazes me that it's so simple to create a network connection
like this! But my basic question is this: would this connection work if
the two computers (each running one of these scripts) were completely
unrelated to one another? My two are on a home network, but if I were to
run the server program and have a friend of mine (who lives somewhere
else) run the client program, would it still work?

-----
#!/usr/bin/env python

from socket import *
from time import ctime

HOST = '192.168.1.100'
PORT = 21567
BUFSIZ = 1024
ADDR = (HOST, PORT)

tcpSerSock = socket(AF_INET, SOCK_STREAM)
tcpSerSock.bind (ADDR)
tcpSerSock.list en(5)

while True:
print 'waiting for connection...'
tcpCliSock, addr = tcpSerSock.acce pt()
print '...connected from:', addr

while True:
data = tcpCliSock.recv (BUFSIZ)
if not data:
break
tcpCliSock.send ('[%s] %s' % (ctime(), data))

tcpCliSock.clos e()

tcpSerSock.clos e()
-----

-----
#!/usr/bin/env python

from socket import *

HOST = '192.168.1.100'
PORT = 21567
BUFSIZ = 1024
ADDR = (HOST, PORT)

tcpCliSock = socket(AF_INET, SOCK_STREAM)
tcpCliSock.conn ect(ADDR)

while True:
data = raw_input('')
if not data:
break
tcpCliSock.send (data)
data = tcpCliSock.recv (BUFSIZ)
if not data:
break
print data

tcpCliSock.clos e()
-----
Jun 27 '08 #3
John Salerno wrote:
-----
#!/usr/bin/env python

from socket import *
from time import ctime

HOST = '192.168.1.100'
-----
#!/usr/bin/env python

from socket import *

HOST = '192.168.1.100'
A question about this. Is the "HOST" referring to the IP address of the
server computer in both of these cases? Because when I ran the program
and got to the part where it says "connected from:" on the server side,
it shows this same IP address. Shouldn't it be something different,
since the requests are coming from a different computer than the server
computer?
Jun 27 '08 #4
On 2008-06-14, John Salerno <jo******@gmail NOSPAM.comwrote :
John Salerno wrote:
>if the program I write actually works and allows the two
computers to speak to each other, will that be a result purely of the
program, or will it have anything to do with the fact that they are
already on a home network together?

Here are the two programs. Server first, then client. They work, which
in itself amazes me that it's so simple to create a network connection
like this! But my basic question is this: would this connection work if
the two computers (each running one of these scripts) were completely
unrelated to one another?
That depends on your definition of "unrelated. "
My two are on a home network, but if I were to run the server
program and have a friend of mine (who lives somewhere else)
run the client program, would it still work?
Yes, if the routers/firewalls/PCs were set up properly and if
you changed the IP addresses in the programs appropriately.

--
Grant Edwards grante Yow! I want the presidency
at so bad I can already taste
visi.com the hors d'oeuvres.
Jun 27 '08 #5
On 2008-06-14, John Salerno <jo******@gmail NOSPAM.comwrote :
John Salerno wrote:
>-----
#!/usr/bin/env python

from socket import *
from time import ctime

HOST = '192.168.1.100'

>-----
#!/usr/bin/env python

from socket import *

HOST = '192.168.1.100'

A question about this. Is the "HOST" referring to the IP
address of the server computer in both of these cases?
Yes.
Because when I ran the program and got to the part where it
says "connected from:" on the server side, it shows this same
IP address.
Then you must have been either running the client program on
the same machine as the server program or you've got some sort
of NAT/port-forwarding going on.
Shouldn't it be something different, since the requests are
coming from a different computer than the server computer?
Works fine for me. When I run the client program on a machine
different than the server program, the server program prints
out "connected from:" and then the client machine's IP address.

--
Grant Edwards grante Yow! Maybe I should have
at asked for my Neutron Bomb
visi.com in PAISLEY --
Jun 27 '08 #6
Grant Edwards wrote:
>Shouldn't it be something different, since the requests are
coming from a different computer than the server computer?

Works fine for me. When I run the client program on a machine
different than the server program, the server program prints
out "connected from:" and then the client machine's IP address.
Hmm, so could the reason that the client request is shown to be coming
from the same IP address as the server machine be that they are on the
same home network?

I guess to truly test my question, I need to have two computers that are
completely "unrelated" to one another -- meaning they are in no way
connected via any type of network prior to running these scripts.
Jun 27 '08 #7
Grant Edwards wrote:
That depends on your definition of "unrelated. "
Heh heh, you mean that wasn't specific enough!? :)

I just mean completely unconnected in any possible way, network or
otherwise.
>My two are on a home network, but if I were to run the server
program and have a friend of mine (who lives somewhere else)
run the client program, would it still work?

Yes, if the routers/firewalls/PCs were set up properly and if
you changed the IP addresses in the programs appropriately.
Ok, that's basically what I was curious about. Since my two computers
are already on a network, I couldn't be positive that this wasn't
allowing them to connect, rather than the two client/server scripts.
Jun 27 '08 #8
On 2008-06-14, John Salerno <jo******@gmail NOSPAM.comwrote :
Grant Edwards wrote:
>>Shouldn't it be something different, since the requests are
coming from a different computer than the server computer?

Works fine for me. When I run the client program on a machine
different than the server program, the server program prints
out "connected from:" and then the client machine's IP address.

Hmm, so could the reason that the client request is shown to be coming
from the same IP address as the server machine be that they are on the
same home network?
No, not for the usual value of "on the same home network".
I've no idea how your home network is set up, so that's about
all I can say.
I guess to truly test my question, I need to have two
computers that are completely "unrelated" to one another --
meaning they are in no way connected via any type of network
prior to running these scripts.
If the two computers are in no way connected via any type of
network, then the two programs won't be able to talk to each
other.

The programs can't create a network, they can only use one that
already exists.

--
Grant Edwards grante Yow! I've got an IDEA!!
at Why don't I STARE at you
visi.com so HARD, you forget your
SOCIAL SECURITY NUMBER!!
Jun 27 '08 #9
On 2008-06-14, John Salerno <jo******@gmail NOSPAM.comwrote :
Grant Edwards wrote:
>That depends on your definition of "unrelated. "

Heh heh, you mean that wasn't specific enough!? :)

I just mean completely unconnected in any possible way, network or
otherwise.
If they're completely unconnected in any possible way, then I
take that to mean that any communication between the two
computers is impossible.

--
Grant Edwards grante Yow! I demand IMPUNITY!
at
visi.com
Jun 27 '08 #10

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

Similar topics

1
9893
by: Matthew Clubb | last post by:
Hi, I need help developing an expanding form I've decided that a use of PHP, Mysql and Javascript is the best platform for creating a selection of database interfaces which I'm trying to build for my company. I had been using Microsoft Access, but obviously this requires licenses for every machine. BUT..... I'm look for an easy way of recreating subforms. I'm trying to create a Purchase Order system and in Access I did this by using a...
0
2571
by: billmiami2 | last post by:
Perhaps many of you MS Access fanatics already know this, but it seems that stored procedures and views are possible in Jet. I thought I would leave this message just in case it would help anyone. I discovered this the other day while doing some experiments with ADO and ADO.NET. Basically, I wanted to run a stored MS Access query with parameters using the syntax Execute MyProcedure @Param1, @Param2...
8
5961
by: Nanda | last post by:
hi, I am trying to generate parameters for the updatecommand at runtime. this.oleDbDeleteCommand1.CommandText=cmdtext; this.oleDbDeleteCommand1.Connection =this.oleDbConnection1; this.oleDbDeleteCommand1.Parameters.Add(new System.Data.OleDb.OleDbParameter("Original_ApplicantName", dataset.Tables.Columns.DataType, 50,
6
18711
by: Andi Reisenhofer | last post by:
Hallo C# folks, Somebody know how to create a ODBC DSN dynamically in c# program. Also interesting for me would be the connectionstring for an Access Database. Thinks a lot Andreas
3
2989
by: kris.dorey | last post by:
Hi, Ive got the following code which seems ok but when the user runs the function for a second time I get an error message stating that the mdb is in use by another process. There is still an ldb for the life of the application even after calling oldebconnection.close and gc.collect. Any ideas?
1
1794
by: Jake Smythe | last post by:
Hello, I have a dataset that is being passed to a webservice. It has about 5 records. I call a stored proc that inserts for the first record but errors out for the others as the connection is already open. I am wanting to have a sql trans open for all so if one of the records fails all are rolled back. Could someone provide me with a simple way to do this? Below is my code. I think I need a main transaction with little ones inside but I...
4
1244
by: ebrastow | last post by:
Hi, I've been using PowerBuilder for 12 years (programming part time) and thought I might give VB a try. I'm using Visual Studio 2005, specifically VB. My SQL Server is SQL Server 2000 Standard, running on a W2K Server. So, in VB, I create a new project, and then click Add New Data Source.. I choose Database as the data source type.
17
46509
Motoma
by: Motoma | last post by:
This article is cross posted from my personal blog. You can find the original article, in all its splendor, at http://motomastyle.com/creating-a-mysql-data-abstraction-layer-in-php/. Introduction: The goal of this tutorial is to design a Data Abstraction Layer (DAL) in PHP, that will allow us to ignore the intricacies of MySQL and focus our attention on our Application Layer and Business Logic. Hopefully, by the end of this guide, you will...
1
1963
by: Carlettus | last post by:
Dear All, sorry but I'm not sure if this is the right place to post my problem. I was using the following asp code to create users in Active Directory. Suddenly, and I don't know the reason, users are created but the account is disabled (see the flag User.AccountDisabled = False ). There is also another problem even if the user does not exist , the application returns to me with the message that the user already exist. Thank you for...
13
12784
by: jkimbler | last post by:
As part of our QA of hardware and firmware for the company I work for, we need to automate some testing of devices and firmware. Since not everybody here knows C#, I'm looking to create a new scripting language that makes writing automated tests simpler. Really, I'm looking to kind of abstract the power of the C# language into a simpler language that's easier to learn. The script files would be interpreted by a script interpreter...
0
8242
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
8177
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
8629
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8341
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,...
1
6112
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
4084
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
2611
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
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1488
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.