Home › Forums › Support › PC terminal and mobile terminal connection cannot be returned › Reply To: PC terminal and mobile terminal connection cannot be returned
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.Xml.Linq;
using FlyOutMenu.Model;
using NetworkCommsDotNet;
using NetworkCommsDotNet.Connections;
using System.Net;
using NetworkCommsDotNet.Connections.TCP;
namespace FlyOutMenu
{
[Activity (Label = "FlyInMenu", MainLauncher = true, Theme = "@android:style/Theme.Holo.Light.NoActionBar")]
public class Login : Activity
{
string ip="192.168.43.155";
int port=6003;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Login);
Button btnLogin = FindViewById<Button>(Resource.Id.login);
btnLogin.Click += new EventHandler(btnLogin_Click);
TextView txtSheZhi = FindViewById<TextView>(Resource.Id.SheZhi);
txtSheZhi.Click += new EventHandler(txtSheZhi_Click);
}
//Trigger when click the login button
void btnLogin_Click(object sender, EventArgs e)
{
try
{
ConnectionInfo info = new ConnectionInfo(ip, port);
TCPConnection conn = TCPConnection.GetConnection(info);
string i = conn.SendReceiveObject<string, string>("Message", "Re", 1000, "Hello word");
Toast.MakeText(this, i, ToastLength.Long).Show();
}
catch (Exception ex)
{
Toast.MakeText(this, ex.ToString(), ToastLength.Long).Show();
}
}
}
}
PC is already successfully received the “Hello word”.
When the PC terminal to send a return value back to the Android, but that such errors.
The same mistake:
NetworkCommsDotNet.ConnectionShutdownException: Remote end closed connection bef
ore data was successfully returned.
at NetworkCommsDotNet.Connections.Connection.SendReceiveObject[String,String]
(System.String sendingPacketTypeStr, System.String expectedReturnPacketTypeStr,
Int32 returnPacketTimeOutMilliSeconds, System.String sendObject, NetworkCommsDot
Net.SendReceiveOptions sendOptions, NetworkCommsDotNet.SendReceiveOptions receiv
eOptions, System.Int64& sentPacketSequenceNumber) [0x00000] in <filename unknown
>:0
at NetworkCommsDotNet.Connections.Connection.SendReceiveObject[String,String]
(System.String sendingPacketTypeStr, System.String expectedReturnPacketTypeStr,
Int32 returnPacketTimeOutMilliSeconds, System.String sendObject, NetworkCommsDot
Net.SendReceiveOptions sendOptions, NetworkCommsDotNet.SendReceiveOptions receiv
eOptions) [0x00000] in <filename unknown>:0
at NetworkCommsDotNet.Connections.Connection.SendReceiveObject[String,String]
(System.String sendingPacketTypeStr, System.String expectedReturnPacketTypeStr,
Int32 returnPacketTimeOutMilliSeconds, System.String sendObject) [0x00000] in <f
ilename unknown>:0
at FlyOutMenu.Login.btnLogin_Click (System.Object sender, System.EventArgs e)
[0x00000] in <filename unknown>:0