Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-blocking socket.accept() behavior differs on platforms #9587

Open
dlangBugzillaToGithub opened this issue Jan 21, 2012 · 1 comment
Open

Comments

@dlangBugzillaToGithub
Copy link

soul8o8 reported this on 2012-01-21T10:47:02Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=7338

CC List

Description

// - - - - - 8< - - - - 
import	std.stdio, std.socket;
void main()
{
	auto lsock = new TcpSocket();
	lsock.blocking(false);
	lsock.bind(new InternetAddress("127.0.0.1",5000));
	try{
		lsock.listen(1);
	}catch(Exception e){
		writeln("listen() failed (This is not the bug, choose another port?)");
		return;
	}

	try{
		auto sock = lsock.accept();
		writeln("Accept returned: ",sock);
	}catch(Exception e){
		writeln("Accept threw Exception:
",e);
	}

	lsock.close();
}
// - - - - - 8< - - - -

Behavior when socket.accept() is called when no new connection is available:

- Linux, OSX: An Exception is thrown
- Windows: A new Socket(isAlive=false) is returned
- Other: <untested>
@dlangBugzillaToGithub
Copy link
Author

bugzilla (@WalterBright) commented on 2019-10-17T19:42:31Z

What is the expected correct behavior?

@LightBender LightBender removed the P3 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants