Problem with udp sockets running through wine

Questions about Wine on Linux
Locked
OzzMan
Newbie
Newbie
Posts: 3
Joined: Thu Nov 21, 2013 4:29 pm

Problem with udp sockets running through wine

Post by OzzMan »

I have an application that's using UDP sockets... in theory the user should be able to freely change the port they're listening on for UDP packets. This works fine in Windows, but through Wine in Linux, usually you can't use the same port number twice because you'll get a failure. My guess on what's happening is that the disassociation between the socket and the port is not happening.

Setup:
- Tried this using winsock and winsock2, same result
- Ubuntu 12.04 LTS (wine 1.4 and 1.4.1)
- RedHat 6.2 (wine 1.4)

To reproduce:
- Set up a winsock socket
- Associate to desired, open port
- Delete socket
- Go to another open port (this works)
- Go back to old port (this fails)

Any ideas? ...or has anyone had a similar experience?
User avatar
dimesio
Moderator
Moderator
Posts: 13367
Joined: Tue Mar 25, 2008 10:30 pm

Re: Problem with udp sockets running through wine

Post by dimesio »

Possibly related: http://bugs.winehq.org/show_bug.cgi?id=26031 and https://bugzilla.kernel.org/show_bug.cgi?id=45571

FYI, your Wine version is old and no longer supported. You should upgrade.
oiaohm
Level 8
Level 8
Posts: 1020
Joined: Fri Feb 29, 2008 2:54 am

Re: Problem with udp sockets running through wine

Post by oiaohm »

OzzMan your theory is invalid. Linux has mandatory time out in case of server/application crash. Windows you can have a hi-jack event.

OzzMan if program is running into a issue with this. Its also not stable if another application happens to be running on the system using the same ports.
Default Linux time out is 60 seconds. So if 60 seconds has past bind to port works again.

- Set up a winsock socket
- Associate to desired, open port
- Delete socket
- Go to another open port (this works)
**Another application under Windows grabs old port**
- Go back to old port(fails due to other application grabbing it)

So its an application bug. Why in hell did it let go of the port in the first place. By letting go another application could claim it.

Wine might have to add some code to deal with this issue. It is possible to adjust the linux kernel wait limits. But the wait limits exist so client at other end should be informed that the connection is ended.

Yes you are part right Linux disassociation is far more strict. Linux does do disassociation without computer on other end of network being informed..

OzzMan what Windows and OS X do with UDP ports is in fact against UDP spec. Welcome to ugly problem.
oiaohm
Level 8
Level 8
Posts: 1020
Joined: Fri Feb 29, 2008 2:54 am

Re: Problem with udp sockets running through wine

Post by oiaohm »

http://stackoverflow.com/questions/1438 ... hey-mean-t

OzzMan its a bit of a problem when the Windows design is defective in this one area.
OzzMan
Newbie
Newbie
Posts: 3
Joined: Thu Nov 21, 2013 4:29 pm

Re: Problem with udp sockets running through wine

Post by OzzMan »

dimesio wrote: FYI, your Wine version is old and no longer supported. You should upgrade.
That is considered the stable version for those Linux distros. Go to download it and you'll see that's what's available.
OzzMan
Newbie
Newbie
Posts: 3
Joined: Thu Nov 21, 2013 4:29 pm

Re: Problem with udp sockets running through wine

Post by OzzMan »

I'm reviewing the posts guys... I guess this is an issue with how the different operating systems implemented the sockets. Great!

Thanks for taking the time to answer... Appreciate it! ...I've never done native Linux sockets so I didn't know about this difference in implementation.
oiaohm
Level 8
Level 8
Posts: 1020
Joined: Fri Feb 29, 2008 2:54 am

Re: Problem with udp sockets running through wine

Post by oiaohm »

OzzMan there are two reasons.

1) is the difference in implementation in sockets.
The other reason
2) Some things are bad design that should not be done even if the OS allows it.

Releasing a socket and expecting to be able to go back and use it is bad design. Linux is one of the few OS's with mandatory time out before sockets can be reused after being released.

OzzMan I would say you did not know enough about Windows Socket either. There are security implementations and other issues that you must be aware of when using sockets.

Just because Windows allows something does not mean you should be doing that. Releasing and then being able to go back and claim the same socket straight way is one of those things even a good Windows Programmer should avoid. Mostly because once released you can never be promised to get it back under Windows. If you do release and you cannot get port back your program should not fail under Windows either. Why this can happen anyhow. The Linux difference just means it happens all the time instead of intermittently. So program failing due to this is a broken program.

Wine does try to support broken programs. But we prefer not having to.
Locked