我正在使用OkHttpClient
,我想通过端口443连接到服务器。
public static String hostUrl = "http://ServerIP/";
RequestBody formBody = new FormBody.Builder()
.add("username", mEmail)
.add("passcode", mPassword)
.build();
Request request = new Request.Builder()
.url(Constant.hostUrl)
.post(formBody)
.build();
OkHttpClient client = new OkHttpClient();
try{
Response response = client.newCall(request).execute();
if(response.code() == 200){
String responseData = response.body().string();
Log.w("responseData", responseData);
//Process the response Data
}else{
//Server problem
Log.w("server problem", "server problem");
}
}catch(IOException ex) {
//Do something with the exception
ex.printStackTrace();
Log.w("send logi data to S Err",ex);
}
答案 0 :(得分:1)
只需将端口号附加到您的基本网址
http://ServerIP:443/