mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 17:12:03 +00:00
fixup wait for connection
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39987 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4b9f685eb9
commit
bd106b0bd0
1 changed files with 15 additions and 7 deletions
|
@ -55,11 +55,15 @@ NSLog(@"%@", notif);
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||||
Handler *h;
|
Handler *h;
|
||||||
NSFileHandle *sFH, *cFH;
|
NSFileHandle *sFH;
|
||||||
NSData *wData = [@"Socket Test" dataUsingEncoding:NSASCIIStringEncoding];
|
NSFileHandle *cFH;
|
||||||
NSData *rData;
|
NSData *wData;
|
||||||
|
NSData *rData;
|
||||||
|
NSDate *limit;
|
||||||
|
|
||||||
|
wData = [@"Socket Test" dataUsingEncoding:NSASCIIStringEncoding];
|
||||||
/* Note that the above data should be short enough to fit into the
|
/* Note that the above data should be short enough to fit into the
|
||||||
socket send buffer otherwise we risk being blocked in this single
|
socket send buffer otherwise we risk being blocked in this single
|
||||||
threaded process. */
|
threaded process. */
|
||||||
|
@ -74,7 +78,6 @@ int main()
|
||||||
|
|
||||||
[sFH acceptConnectionInBackgroundAndNotify];
|
[sFH acceptConnectionInBackgroundAndNotify];
|
||||||
|
|
||||||
|
|
||||||
cFH = [NSFileHandle fileHandleAsClientAtAddress: @"127.0.0.1"
|
cFH = [NSFileHandle fileHandleAsClientAtAddress: @"127.0.0.1"
|
||||||
service: GST_PORT
|
service: GST_PORT
|
||||||
protocol: @"tcp"];
|
protocol: @"tcp"];
|
||||||
|
@ -82,7 +85,12 @@ int main()
|
||||||
"NSFileHandle understands +fileHandleAsClientAtAddress:");
|
"NSFileHandle understands +fileHandleAsClientAtAddress:");
|
||||||
|
|
||||||
[cFH writeData: wData];
|
[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");
|
PASS(rFH != nil, "NSFileHandle connection was made");
|
||||||
|
|
||||||
rData = [rFH availableData];
|
rData = [rFH availableData];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue