Multiple GCDAsyncSocket connections won't accept data from multiple sockets

I am trying to write an application that connects to multiple sockets at the same time, I am having problems getting data from the old socket when connecting a new one.

The main thing is that the delegate is not activated by the previously connected socket.

This is my general program

var struct = [serverlist]() //Create array for sockets and 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 like print data
}

      

This is my structure for storing sockets

struct serverlist 
{ 
    var Serveraddress = String(); 
    var socket = GCDAsyncSocket?(); 
}

      

Note I have verified that both sockets are still connected to different IPs with the code below.

println(Liststucture[x].socket?.isDisconnected) 
println(Liststucture[x].socket?.connectedHost) 

      

+3
swift gcdasyncsocket


source to share


No one has answered this question yet

See similar questions:

0
Delegate does not receive a set

or similar:

3
Multiple GCDAsyncSocket connections?
2
GCDAsyncSocket in browser connects immediately and disconnects on error "Socket closed by remote peer"
1
Will data from two different sources collide in GCDAsyncSocket?
0
Telnet connection to Xcode GCDAsyncSocket
0
GCDAsyncSocket connect to path
0
Error reading GCDAsyncSocket
0
Error updating cell with data from Parse
0
Quickly create a socket client with GCDAsyncSocket
0
GCDAsyncSocket: [socket acceptOnPort: error:] does not accept
0
Ocj-C Secure Sockets Server with real SSL protocol certification (based on GCDAsyncSockets)



All Articles
Loading...
X
Show
Funny
Dev
Pics