create two socket connection in one thread

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 08:28:11

问题


In my application i want to share file between a server and client, for that purpose i want to create two socket connection in one thread. For example at server we have thread "T" and it has opened two socket like "1234" and socket no "3456" now on the client thread "T2" i will try to connect with these sockets. So how i should implement it.

server:

thread 
{
wait at socket "1234"
wait at socket "3456"
}

CLIENT SIDE:

Thread 
{
connect with socket no "1234"
connect with socket no "3456"
}

回答1:


if you have well implemented protocol(ie. each socket will send the data in a definite order), yeah one thread should work. but you can do this using only one socket connection too. what is the main point of creating two sockets? and what is the relation with android?

in addition; you definitely have to elaborate your question, otherwise it seems the question will be closed soon.



来源:https://stackoverflow.com/questions/15311029/create-two-socket-connection-in-one-thread

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!