Author: rfm
Date: Tue Jul 12 18:25:49 2016
New Revision: 39987
URL: http://svn.gna.org/viewcvs/gnustep?rev=39987&view=rev
Log:
fixup wait for connection
Modified:
libs/base/trunk/Tests/base/NSFileHandle/socket.m
Modified: libs/base/trunk/Tests/base/NSFileHandle/socket.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/base/trunk/Tests/base/NSFileHandle/socket.m?rev=39987&r1=39986&r2=39987&view=diff
==============================================================================
--- libs/base/trunk/Tests/base/NSFileHandle/socket.m (original)
+++ libs/base/trunk/Tests/base/NSFileHandle/socket.m Tue Jul 12 18:25:49 2016
@@ -55,11 +55,15 @@
int main()
{
- NSAutoreleasePool *arp = [NSAutoreleasePool new];
- Handler *h;
- NSFileHandle *sFH, *cFH;
- NSData *wData = [@"Socket Test" dataUsingEncoding:NSASCIIStringEncoding];
- NSData *rData;
+ NSAutoreleasePool *arp = [NSAutoreleasePool new];
+ Handler *h;
+ NSFileHandle *sFH;
+ NSFileHandle *cFH;
+ NSData *wData;
+ NSData *rData;
+ NSDate *limit;
+
+ wData = [@"Socket Test" dataUsingEncoding:NSASCIIStringEncoding];
/* Note that the above data should be short enough to fit into the
socket send buffer otherwise we risk being blocked in this single
threaded process. */
@@ -74,7 +78,6 @@
[sFH acceptConnectionInBackgroundAndNotify];
-
cFH = [NSFileHandle fileHandleAsClientAtAddress: @"127.0.0.1"
service: GST_PORT
protocol: @"tcp"];
@@ -82,7 +85,12 @@
"NSFileHandle understands +fileHandleAsClientAtAddress:");
[cFH writeData: wData];
- [[NSRunLoop currentRunLoop] run];
+ limit = [NSDate dateWithTimeIntervalSinceNow: 2.0];
+ while (nil == rFH && [limit timeIntervalSinceNow] > 0.0)
+ {
+ [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode
+ beforeDate: limit];
+ }
PASS(rFH != nil, "NSFileHandle connection was made");
rData = [rFH availableData];
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs