Skip to content

Commit 89dc739

Browse files
Copilotdustturtle
andcommitted
Use PID-based unique filename for Unix domain socket in demo
Co-authored-by: dustturtle <2305214+dustturtle@users.noreply.github.com>
1 parent 6f0c457 commit 89dc739

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

ObjC/ObjCDemo/main.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
//
2828

2929
#import <Foundation/Foundation.h>
30+
#include <unistd.h>
3031
#import "NWStreamBuffer.h"
3132
#import "NWSSEParser.h"
3233
#import "NWReadRequest.h"
@@ -655,7 +656,8 @@ static void demoServerSocket(void) {
655656

656657
GCDAsyncSocket *udsServer = [[GCDAsyncSocket alloc] initWithDelegate:delegate
657658
delegateQueue:queue];
658-
NSString *tmpPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"nwasyncsocket_demo.sock"];
659+
NSString *tmpPath = [NSTemporaryDirectory() stringByAppendingPathComponent:
660+
[NSString stringWithFormat:@"nwasyncsocket_demo_%d.sock", getpid()]];
659661
NSURL *sockURL = [NSURL fileURLWithPath:tmpPath];
660662
NSError *udsErr = nil;
661663
BOOL udsOk = [udsServer acceptOnUrl:sockURL error:&udsErr];

0 commit comments

Comments
 (0)