>From 3d79893350675549f9df7644e3b413a4395f717d Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Wed, 19 Jan 2011 17:02:53 +0100 Subject: [PATCH] sockets: Make ServerSocket fail if one attempts to bind the same port 2011-01-19 Holger Hans Peter Freyther * package.xml: Add TestCases.st as SUnit test. * Sockets.st: Use File checkError to check errno and not soError. * TestCases.st: Add file for SUnit test case. --- packages/sockets/AbstractSocketImpl.st | 2 +- packages/sockets/ChangeLog | 6 ++++++ packages/sockets/TestCases.st | 11 +++++++++++ packages/sockets/package.xml | 5 +++++ 4 files changed, 23 insertions(+), 1 deletions(-) create mode 100644 packages/sockets/TestCases.st diff --git a/packages/sockets/AbstractSocketImpl.st b/packages/sockets/AbstractSocketImpl.st index 992b7f6..9464cc7 100644 --- a/packages/sockets/AbstractSocketImpl.st +++ b/packages/sockets/AbstractSocketImpl.st @@ -112,7 +112,7 @@ this can be changed by class methods on SocketAddress sublcasses.'> [(self bind: fd to: addr - addrLen: addr size) < 0 ifTrue: [File checkError: self soError] ] + addrLen: addr size) < 0 ifTrue: [File checkError] ] ifCurtailed: [self close]. self isOpen ifTrue: [self hasBeenBound] ] diff --git a/packages/sockets/ChangeLog b/packages/sockets/ChangeLog index 20a9bc6..94de2c6 100644 --- a/packages/sockets/ChangeLog +++ b/packages/sockets/ChangeLog @@ -1,3 +1,9 @@ +2011-01-19 Holger Hans Peter Freyther + + * package.xml: Add TestCases.st as SUnit test. + * Sockets.st: Use File checkError to check errno and not soError. + * TestCases.st: Add file for SUnit test case. + 2010-12-04 Paolo Bonzini * package.xml: Remove now superfluous tags. diff --git a/packages/sockets/TestCases.st b/packages/sockets/TestCases.st new file mode 100644 index 0000000..7e9808c --- /dev/null +++ b/packages/sockets/TestCases.st @@ -0,0 +1,11 @@ +TestCase subclass: TCPBindTest [ + + + testMultipleBind [ + | socket1 socket2 | + + socket1 := ServerSocket port: 6666. + self should: [socket2 := ServerSocket port: 6666] + raise: SystemExceptions.FileError. + ] +] diff --git a/packages/sockets/package.xml b/packages/sockets/package.xml index 079ea0c..46774d0 100644 --- a/packages/sockets/package.xml +++ b/packages/sockets/package.xml @@ -16,4 +16,9 @@ cfuncs.st init.st ChangeLog + + + Sockets.TCPBindTest + TestCases.st + -- 1.7.3.4