1

I am now using AsyncSocket for iPhone socketing connection development. http://code.google.com/p/cocoaasyncsocket/

But I am having problem that, how to connect 2 multi-server to collect data from server?

I have host IP address A: 201.22.33.XXX.XX and host IP address B: 202.33.XXX.XX

I can success connect one server to collect data. But how to collect both server at the same time?

I tried create two socket objects with their own delegates, my path is like that:
step 1 ---- Connect to A step 2 ---- Connect to B Step 3 ---- Disconnect B but at this moment when i disconnect B, A also disconnected....

Please help.

User97693321
  • 3,336
  • 7
  • 45
  • 69
nullmicgo
  • 407
  • 4
  • 19

1 Answers1

1

You'll need to create two socket objects with their own delegates. I have several applications that connect to multiple servers at once.

Flyingdiver
  • 2,142
  • 13
  • 18
  • can you give me more information about two socket objects with their own delegates? – nullmicgo Dec 21 '11 at 08:54
  • I tried create two socket objects with their own delegates, my path is like that: step 1 ==== Connect to A step 2 ==== Connect to B Step 3 ==== Disconnect B but at this moment when i disconnect B, A also disconnected.... please help >. – nullmicgo Feb 08 '12 at 02:10
  • I am still have trouble with this issue, would u mind make a simple example to explain?thx !! – nullmicgo Feb 14 '12 at 06:38
  • I am still having problem with this question,please help >. – nullmicgo Mar 23 '12 at 08:04
  • It sounds as if the delegates for A and B could be referencing the same object. Did you accidentally set the delegate for both AsyncSocket A and B objects to the same object (such as `self`?) You might want something like this (example only; I have never used AsyncSocket): `AsyncSocket *soA = [[AsyncSocket alloc] init]; [soA setDelegate:delegateObjectA]; AsyncSocket *soB = [[AsyncSocket alloc] init]; [soB setDelegate:delegateObjectB];` – Steve HHH Mar 23 '12 at 19:54
  • @nullmicgo If your problem is solved,please explain and accept the answer. – User97693321 Oct 22 '12 at 12:51
  • I did not found out the answer yet... For now,i opened two different AsyncSocketDelegate, for example, if you want to have two socket connection together, my method is FirstAsyncSocketDelegate.h FirstAsyncSocketDelegate.m SecondAsyncSocketDelegate.h SecondAsyncSocketDelegate.m But this method still having trouble sometimes...such as close one connection , and another also closed sometimes.. – nullmicgo Oct 22 '12 at 14:32