swift - GCDAsyncSocket multiple connections wont accept data from multiple sockets -
i trying write app connects multiple sockets @ same time, i'm having trouble receiving data old socket when new 1 connected.
the main thing delegate not activated connected socket.
this overall program
var struct = [serverlist]() //create array sockets , serverinfo func connect() { //init socket struct[item].socket = gcdasyncsocket(delegate: self, delegatequeue: dispatch_get_main_queue()) //create error message var connectionerror: nserror? //connect socket struct[item].socket!.connecttohost(struct[item].serveraddress, onport: struct[item].serverport, error: &connectionerror) } func socket(socket : gcdasyncsocket, didreaddata data:nsdata, withtag tag:int32) { //do stuff print data }
this structure store sockets
struct serverlist { var serveraddress = string(); var socket = gcdasyncsocket?(); }
note have checked both sockets still connected different ip addresses code below.
println(liststucture[x].socket?.isdisconnected) println(liststucture[x].socket?.connectedhost)
Comments
Post a Comment