मैं एंड्रॉइड के लिए एक मोबाइल एप्लिकेशन विकसित कर रहा हूं। वहां, मैं एंड्रॉइड मोबाइल और विंडोज़ एप्लिकेशन (जो पीसी, लैपटॉप पर चल रहा है) के बीच सॉकेट और ट्रांसफर डेटा बना रहा है। मैं एंड्रॉयड 2.3एंड्रॉइड में java.net सॉकेट का डिफ़ॉल्ट समय मूल्य क्या है?
परीक्षण मोबाइल सैमसंग गैलेक्सी पॉप
पीसी का उपयोग कर रहा और मोबाइल यूएसबी tithering के माध्यम से जुड़े हुए हैं।
डेटा स्थानांतरण सही ढंग से।
लेकिन एप्लिकेशन के बीच में एक समस्या है सिस्टम को मोबाइल यूएसबी कैपल को अनप्लग करके रद्द करने के बाद, तो मैं अपवाद फेंकता हूं।
लेकिन कुछ समय यह किसी भी अपवाद यह बस इंतजार कर रहा है के माध्यम से नहीं है,
पढ़ने इसलिए कृपया में एंड्रॉयड
मेरे नमूना कोड नीचे दिए गए हैं समय भेज डिफ़ॉल्ट सॉकेट समय के लिए बाहर के लिए डेटा के लिए सॉकेट भी नहीं बंद प्रतीक्षा करता है
Socket socket=null;
DataOutputStream dos=null;
OutputStream os=null;
InputStream is=null;
DataInputStream dis=null;
try
{
Log.i(tagName, "b4 creating socket");
socket=new Socket(this.getIpAddress(),this.getPort_number());
is=socket.getInputStream();
dos=new DataOutputStream(os);
dis=new DataInputStream(is);
}
catch(UnknownHostException unknown_ex)
{
Log.i(tagName, "Exception host unknown : "+unknown_ex.toString());
unknown_ex.printStackTrace();
}
catch(IOException ioe_ex)
{
Log.i(tagName, "ioe Exception : "+ioe_ex.toString());
ioe_ex.printStackTrace();
}
catch(Exception ex)
{
Log.i(tagName, "Exception : "+ex.toString());
ex.printStackTrace();
}
if(dos!=null)
{
try
{
dos.close();
}
catch(Exception ex)
{
}
}
if(dis!=null)
{
try
{
dis.close();
}
catch(Exception ex){}
}
if(socket!=null)
{
try
{
socket.close();
}
catch(Exception ex)
{
}
}
socket=null;dos=null;dis=null;
Log.i(tagName, "MySocketConnection.connectMe() - end");
जब मैं कोड का उपयोग
Socket.getSoTimeout()
फिर यह 0
कृपया सभी अपने विचार दें।
जब आप 'Socket.getSoTimeout()' पर कॉल करते हैं तो आपको क्या मूल्य मिलता है? –