473,670 Members | 2,401 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 1837
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,L OOPBACK,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(s ocket.AF_NET,so cket.SOCK_STREA M)

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
3888
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 support for sockets to the system. Thread needs to unblock when: - there is socket ready to be read, or
4
2161
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 create a socket, bind it to a port, put it in listen mode, and then n sockets can connect to it. The code: Socket newSocket = listeningSocket.Accept(); returns a socket. I can communicate on newSocket, and listeningSocket goes
3
2483
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 included. Is there any standard cross-platform way (ie can compile in both Visual C++ 6 and GCC) to execute and connect to other programs? Thanks, John P
6
6986
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
2348
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 SocketOptionName.SendTimeout for sends on TCPIP sockets. In all the tests that I have done with both Async and Sync sends the send returns immediately with the number of bytes sent (< 100 in my messages).
4
7094
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. But how do I pass a username and password? How can I change directories? --------------------------------------------- using System;
0
1152
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. --------------------------------------------------------------------------------------------- What new functionality is added to this feature in Windows XP Service Pack 2? Restricted traffic over raw sockets Detailed description
2
3591
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 a service (for the server side) that accepts incoming client connections using system.net.sockets? -- Sean McIntire
0
8388
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
8907
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...
0
8817
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
8593
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
8663
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
7423
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
6218
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
4396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.