473,513 Members | 2,684 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sockets on Windows and Mac

I am new to Python and have been writing some socket based programmes
on Windows (with some success), however I am unable to get them to work
on Mac.

Are there differences in the way the socket module works on Windows and
Mac? I would appreciate any simple code samples people my have for
creating a very basic server on Macpython, I have copied code from
various tutorials but as yet they don't appear to work.

Thanks,

rod

Jan 8 '06 #1
8 1814
rodmc wrote:
I am new to Python and have been writing some socket based programmes
on Windows (with some success), however I am unable to get them to work
on Mac.


Please elaborate on "unable to get them to work". What problems do you see?

In my experience, there is no difference with the Mac. I'm using a
mac (with OS X tiger) myself.
--Irmen
Jan 8 '06 #2
rodmc wrote:
I am new to Python and have been writing some socket based programmes
on Windows (with some success), however I am unable to get them to work
on Mac.

Are there differences in the way the socket module works on Windows and
Mac? I would appreciate any simple code samples people my have for
creating a very basic server on Macpython, I have copied code from
various tutorials but as yet they don't appear to work.


Aren't you basing this on the standard library modules such as
SocketServer, or extension packages like Twisted, that already do most
of the work for you? If you were, you likely wouldn't have to deal with
any such Mac-specific problems (if that's really what they are) and you
would likely save yourself a whole heck of a lot of time reinventing the
wheel too. (Note also that most people doing raw socket programming do
it wrong, which is a good reason to jump straight ahead to build on the
work of others.)

-Peter

Jan 8 '06 #3
rodmc <ro***@userpro.com> wrote:
I am new to Python and have been writing some socket based programmes
on Windows (with some success), however I am unable to get them to work
on Mac.

Are there differences in the way the socket module works on Windows and
Mac? I would appreciate any simple code samples people my have for
creating a very basic server on Macpython, I have copied code from
various tutorials but as yet they don't appear to work.


Assuming you mean the MacOS X which has been current, in one version or
another, for the last few years (I don't know anything about ancient
OS's such as MacOS 9 etc), I've personally tested all the socket
programming examples from the Nutshell on MacOS X 10.3 and 10.4 (Panther
and Tiger), and they do, of course, run just fine. You can download the
zipfile with all the examples of "Python in a Nutshell" from the
O'Reilly site, even if you don't own the book, and try them. Of course,
you must run a server and one or more client from different Terminal
windows -- that's about the only important (but totally obvious)
precaution you should take.

I don't think you can set the Mac's firewall to impede communication
within the localhost, but I admit I haven't tried -- so, if you have any
problem, detach your Mac from any networks and then in System
Preferences disable the firewall entirely (and make sure your Mac
doesn't erroneously believe it DOES have external networks, i.e., only
"networking" is to/from '127.0.0.1', the local host, AKA the loopback or
'lo0' interface). If you STILL have problems after that, copy and paste
the output of ifconfig, it should start something like:

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet 127.0.0.1 netmask 0xff000000

and also any current messages from an instance of
Applications/Utilities/Console -- as well of course as error messages
and tracebacks, if any, from your Python scripts, but I think any
problem must result from some weird issue with system settings rather
than any programming issue. Do remember to copy and paste, NOT
summarize in your own words, otherwise you may make it unfeasible for us
to help you out!
Alex
Jan 8 '06 #4
Hi Peter,

I am currently importing the socket library when I write the programs,
I have had no problems with it on my PC at work, but the Mac at home
steadfastly refuses to work. As for existing libraries, I am new to
Python so am kean to avoid re-inventing the wheel :-)

Cheers,

rod

Jan 9 '06 #5
Hi Peter,

I am currently importing the socket library when I write the programs,
I have had no problems with it on my PC at work, but the Mac at home
steadfastly refuses to work. As for existing libraries, I am new to
Python so am kean to avoid re-inventing the wheel :-)

Cheers,

rod

Jan 9 '06 #6
I am on 10.3, I keep getting exceptions when it hits lines like

mySocket.bind (SERVER_IP, 2727 )
or
mySocket = socket.socket(socket.AF_NET,socket.SOCK_STREAM)

The code I am using is copied from a tutorial on a website somewhere.

Cheers,

rod

Jan 9 '06 #7
On 2006-01-08, rodmc <ro***@userpro.com> wrote:
I am currently importing the socket library when I write the programs,
I have had no problems with it on my PC at work, but the Mac at home
steadfastly refuses to work.


Well, with details like that, we'll have your problem figured
out in no time!

--
Grant Edwards grante Yow! I HAVE a towel.
at
visi.com
Jan 9 '06 #8
rodmc wrote:
I am currently importing the socket library when I write the programs,
I have had no problems with it on my PC at work, but the Mac at home
steadfastly refuses to work.


One rule about asking for help in forums like this is to provide
adequate background detail about your environment. Generally that
includes version numbers of things. What versions of Python are you
trying to work with?

Note that the code you posted, from that tutorial, is out of date and
needs to be fixed for recent versions of Python, where the argument to
..bind() is a single tuple, not two separate arguments.

Anyway, next time please post snippets of your actual code, with the
error tracebacks *cut and pasted* right out of your terminal window, so
that you don't waste our time by making us guess what you're actually
doing. That way you'll get quick and accurate assistance and keep
everyone helping you happy. :-)

-Peter

Jan 10 '06 #9

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

Similar topics

2
3880
by: Tero Saarni | last post by:
Hi, I have several threads communicating with each other using events stored in Queues. Threads block on Queue.get() until somebody publishes an event in thread's event queue. I need to add...
4
2139
by: 0to60 | last post by:
I have a question about socket programming in general. Exactly what happens behind the scenes when I one socket connects to a different socket in listen mode? Using the dotnet framework, I...
3
2468
by: John P | last post by:
Hi, I know that some older Unix programs that compile with GCC use socket.h to connect to and execute other programs. However, I am using Visual C++ 6.0 and it doesn't seem to have socket.h...
6
6953
by: Laxmikant Rashinkar | last post by:
Is there any way to use a C# socket in promiscuous mode? Any sample code that shows how this is done? any assistance is much appreciated! thanks LK
0
2341
by: Stuart Norris | last post by:
Dear Group, I am having a problem setting SocketOptionName.SendTimeout on a client TCPIP application using the sockets in .NET. From the on-line help it is possible to set a...
4
7082
by: Ron | last post by:
Greetings, below is a sample app for connecting to a mainframe server using Sockets for the purpose of using FTP service to interact with it from a PC. I got as far as creating the connection....
0
1144
by: richard.charts | last post by:
Well, unfortunately, I couldn't get any answer on the msdn forums, so I'll give it a shot here. Real question at the bottom....
2
3574
by: =?Utf-8?B?U2Vhbk1hYw==?= | last post by:
I am familiar with how to use winsock in vb6 to create a network app. I'm trying to find a way to take the current vb6 app and create a windows service using system.net.sockets. How do you create...
0
7257
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
7157
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
7379
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,...
1
7098
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...
0
7521
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...
1
5084
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...
0
3232
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...
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
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...

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.