相关疑难解决方法(0)

DEBUG/SntpClient(60):请求时间失败:java.net.SocketException:协议不支持的地址族

我在Linux控制台上运行服务器,用C语言编写并在android中创建客户端.我没有在DDMS上收到任何错误但是在调试消息之后

11-12 20:38:06.787: DEBUG/SntpClient(60): request time failed: 
java.net.SocketException: Address family not supported by protocol
Run Code Online (Sandbox Code Playgroud)

但是消息不会发送到服务器.但是如果在C或java中创建客户端它工作正常.任何建议.

public class UDPDemo extends Activity {
    private EditText mEditText;
    private Button sendButton;
    private DatagramSocket client_socket;
    private static InetAddress IPAddress;
    private byte[] send_data = new byte[1024];
    static{
    try {
     IPAddress =  InetAddress.getByName("127.0.0.1");
 } catch (UnknownHostException e1) {
 e1.printStackTrace();
 }
} 

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mEditText = (EditText)findViewById(R.id.EditText01);
    sendButton = (Button)findViewById(R.id.Button01);
    sendButton.setOnTouchListener( send);
 } …
Run Code Online (Sandbox Code Playgroud)

android

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×1