SCRCPY-C-Sharp-Client icon indicating copy to clipboard operation
SCRCPY-C-Sharp-Client copied to clipboard

ALWAYS OPEN

Open qaisbayabani opened this issue 4 years ago • 23 comments

qaisbayabani avatar Dec 03 '20 12:12 qaisbayabani

Genymobile/scrcpy#1073 ok

Is it possible to add sending custom adb commands through scrcpy server?

unofficialdev avatar Apr 13 '21 13:04 unofficialdev

Genymobile/scrcpy#1073 ok

Is it possible to add sending custom adb commands through scrcpy server?

adb commands are used to send commands from computer to android phone to do some task.

dear scrcpy server is an android studio code which generates a server.jar file and than a program/application as mine from our computer send/run server.jar to mobile phone with use of adb commands and it runs on android device. as server is already running on android device so we dont have to send any adb command through server. we can do any task on android directly by using scrcpy server by modifying its code its like building another app of android.

qaisbayabani avatar Apr 22 '21 20:04 qaisbayabani

why still print Empty in windows console ? image.Empty() return true ? why ?

cmdszh avatar Oct 09 '21 17:10 cmdszh

why still print Empty in windows console ? image.Empty() return true ? why? change your IP addresses according to your own network environment

qaisbayabani avatar Oct 10 '21 05:10 qaisbayabani

why still print Empty in windows console ? image.Empty() return true ? why? change your IP addresses according to your own network environment

my device is Samsung S6 ,do the flowing things make it correct.
1.change http://127.0.0.1:27184 to tcp://127.0.0.1:27184 2.upgrade 1.12.1 to 1.13

this program make me understand the scrcpy basic protocol , shown me a direction to diving in scrcpy source code.

Thanks so much.

cmdszh avatar Oct 10 '21 08:10 cmdszh

device model is not the concern. a linux based server is running on your pc so its using tcp:// instead of http://

qaisbayabani avatar Oct 10 '21 13:10 qaisbayabani

Hello, can I get some help? I don't know what ip should I put in adb connect. I'm just plugging in the device using USB and I have USB debugging enabled. When I run it gives me this:

Entered in 2nd thread
Waiting for a connection Server No.1----------
cannot connect to 192.168.0.2:5555: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)

 scrcpy-server: 1 file pushed, 0 skipped. 88.5 MB/s (37330 bytes in 0.000s)

 java.io.IOException: Address already in use
        at android.net.LocalSocketImpl.bindLocal(Native Method)
        at android.net.LocalSocketImpl.bind(LocalSocketImpl.java:278)
        at android.net.LocalServerSocket.<init>(LocalServerSocket.java:49)
        at com.genymobile.scrcpy.DesktopConnection.open(DesktopConnection.java:48)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:57)
        at com.genymobile.scrcpy.Server.main(Server.java:255)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:463)

 [server] INFO: Device: Xiaomi M2102J20SG (Android 11)

 [server] ERROR: Exception on thread Thread[main,5,main]

SoareIL avatar Oct 14 '21 09:10 SoareIL

Hello, can I get some help? I don't know what ip should I put in adb connect. I'm just plugging in the device using USB and I have USB debugging enabled. When I run it gives me this:

Entered in 2nd thread
Waiting for a connection Server No.1----------
cannot connect to 192.168.0.2:5555: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)

 scrcpy-server: 1 file pushed, 0 skipped. 88.5 MB/s (37330 bytes in 0.000s)

 java.io.IOException: Address already in use
        at android.net.LocalSocketImpl.bindLocal(Native Method)
        at android.net.LocalSocketImpl.bind(LocalSocketImpl.java:278)
        at android.net.LocalServerSocket.<init>(LocalServerSocket.java:49)
        at com.genymobile.scrcpy.DesktopConnection.open(DesktopConnection.java:48)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:57)
        at com.genymobile.scrcpy.Server.main(Server.java:255)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:463)

 [server] INFO: Device: Xiaomi M2102J20SG (Android 11)

 [server] ERROR: Exception on thread Thread[main,5,main]

Since I don't plan to connect wirelessly to the device I deleted the adb connect process.

Address already in use was solved by modifying the arguments when starting scrcpy-server. More specifically the forward or reverse mode argument: server->tunnel_forward ? "true" : "false"

My arguments as of this moment look like this:

ps.Arguments = "shell " + "CLASSPATH=/data/local/tmp/scrcpy-server.jar " +
                                "app_process " + "/ " + "com.genymobile.scrcpy.Server " +
                                "1.19 " +    //SCRCPY_VERSION
                                "info " +    //log_level_to_server_string(params->log_level)
                                "1024 " +    //max_size_string
                                "8000000 " + //bit_rate_string (8MB)
                                "0 " +       //max_fps_string (adaptive)
                                "-1 " +      //lock_video_orientation_string
                                "false " +   //server->tunnel_forward ? "true" : "false" (false for reverse mode)
                                "- " +       //params->crop ? params->crop : "-"
                                "false " +    //"true", // always send frame meta (packet boundaries + timestamp)
                                "false " +   //params->control ? "true" : "false"
                                "0 " +       //display_id_string
                                "false " +   //params->show_touches ? "true" : "false"
                                "true " +    //params->stay_awake ? "true" : "false"
                                "- " +       //params->codec_options ? params->codec_options : "-"
                                "- " +       //params->encoder_name ? params->encoder_name : "-"
                                "false";     //params->power_off_on_close ? "true" : "false"

Now my problem is getting Empty outputs from the device after this exception:

Third is Gneeal :
System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.IO.BufferedStream.FlushWrite()
   at System.IO.BufferedStream.Flush()
   at Program.ForFun.Fun() in C:\Users\soare\source\repos\cs_scrcpy\cs_scrcpy\Program.cs:line 254

SoareIL avatar Oct 16 '21 07:10 SoareIL

Third is Gneeal : System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.IO.BufferedStream.FlushWrite() at System.IO.BufferedStream.Flush() at Program.ForFun.Fun() in C:\Users\soare\source\repos\cs_scrcpy\cs_scrcpy\Program.cs:line 254

The exception is caused by this line:

VideoCapture capture = new VideoCapture("http://127.0.0.1:27184");

SoareIL avatar Oct 16 '21 13:10 SoareIL

Third is Gneeal : System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size) at System.IO.BufferedStream.FlushWrite() at System.IO.BufferedStream.Flush() at Program.ForFun.Fun() in C:\Users\soare\source\repos\cs_scrcpy\cs_scrcpy\Program.cs:line 254

The exception is caused by this line:

VideoCapture capture = new VideoCapture("http://127.0.0.1:27184");

first of all i have not yet studied or modified it with SCRCPY 1.17 and 2ndly you may have also using an apachi or linux based server on your computer so you may use tcp:// instead of http://127.0.0.1 :27184 may this solve.

i dont know but if you follow exactly my instructions and versions there will be no problem. now taking it to advance level is your headache to modify or use it with next editions of scrcpy

qaisbayabani avatar Oct 17 '21 06:10 qaisbayabani

first of all i have not yet studied or modified it with SCRCPY 1.17 and 2ndly you may have also using an apachi or linux based server on your computer so you may use tcp:// instead of http://127.0.0.1 :27184 may this solve.

i dont know but if you follow exactly my instructions and versions there will be no problem. now taking it to advance level is your headache to modify or use it with next editions of scrcpy

I reverted back to scrcpy-server version 1.12.1 with v1.12.1 arguments and changed VideoCapture to VideoCapture capture = new VideoCapture("tcp://127.0.0.1:27184"); but still the same exception occurs.

SoareIL avatar Oct 17 '21 07:10 SoareIL

first of all i have not yet studied or modified it with SCRCPY 1.17 and 2ndly you may have also using an apachi or linux based server on your computer so you may use tcp:// instead of http://127.0.0.1 :27184 may this solve. i dont know but if you follow exactly my instructions and versions there will be no problem. now taking it to advance level is your headache to modify or use it with next editions of scrcpy

I reverted back to scrcpy-server version 1.12.1 with v1.12.1 arguments and changed VideoCapture to VideoCapture capture = new VideoCapture("tcp://127.0.0.1:27184"); but still the same exception occurs.

try install Microsoft IIS and uninstal any other linux based server running of your pc and follow all the instructions strictly. and use correct version of opencv sharp "4.3.0.20200421"

qaisbayabani avatar Oct 17 '21 21:10 qaisbayabani

I can't make it work whatever I try to do. I don't have any linux on my pc, just windows. I tried to install Microsoft IIS still nothing. I tried opencvsharp version "4.3.0.20200421" still nothing. I guess I'll have to find another way to decode and display the video data sent by scrcpy-server. Thank you for all your help sir.

SoareIL avatar Oct 27 '21 14:10 SoareIL

Hey, I've been stuck on this for quite a while. Its the connecting the the localhost:port part to actually view the video. I'm using Emgu.cv instead but it is mostly the same.

        private void videoListener()
        {
            _capture = new VideoCapture("http://127.0.0.1:27184", VideoCapture.API.Any); //FAILURE HERE
            _capture.ImageGrabbed += ProcessFrame;
            _capture.Set(Emgu.CV.CvEnum.CapProp.Fps, 60);
            _frame = new Mat();

            if (_capture != null)
            {
                try
                {
                    _capture.Start();
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message, Logger.LogType.Error);
                }
            }
        }

It breaks at that line and cannot figure out what to do with the data. However, looking at it in ncat, I can see plenty of data being streamed.

Do you have any idea what could be causing this? Been at it for nearly 6 hours and made no progress because of this.

This is my stream code :

        private void startClient()
        {
            byte[] bb1 = new byte[64];
            byte[] bb2 = new byte[4];
            byte[] bb3 = new byte[12];

            server = new TcpListener(localip, port);
            server1 = new TcpListener(localip, port1);

            server.Start();
            server1.Start();

            Logger.Log("Waiting for Stage 1", Logger.LogType.Message);
            client = server.AcceptTcpClient();
            if (client.Connected)
                Logger.Log("Stage 1 Completed");

            stream = client.GetStream();
            BufferedStream bf = new BufferedStream(stream);

            bf.Read(bb1, 0, bb1.Length);
            Logger.Log(Encoding.ASCII.GetString(bb1, 0, bb1.Length), Logger.LogType.Receive);
            bf.Read(bb2, 0, bb2.Length);
            Logger.Log(Encoding.ASCII.GetString(bb2, 0, bb2.Length), Logger.LogType.Receive);

            new Thread(() => { videoListener(); }).Start();
            
            Logger.Log("Waiting for Stage 2", Logger.LogType.Message);
            client1 = server1.AcceptTcpClient();
            if (client1.Connected)
                Logger.Log("Stage 2 Completed");

            stream1 = client1.GetStream();
            BufferedStream bf1 = new BufferedStream(stream1);
            bf.Read(bb3, 0, bb3.Length);
            Logger.Log("Stream Connected!", Logger.LogType.Message);
            try
            {
                while (bf.Read(bb3, 0, bb3.Length) > 0)
                {
                    bf.Flush();
                    bf1.Flush();
                    bf1.Write(bb3, 0, bb3.Length);
                }
            } catch (Exception) { Logger.Log("Stream Disconnected!", Logger.LogType.Error); }
        }

ADB Server Start Command :

CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 1.21 max_size=1024 bit_rate=8000000 max_fps=0 tunnel_forward=false control=false display_id=0 show_touches=false stay_awake=true

Hopefully, you can at least point me in the right direction.

Thank you.

RealIndica avatar Dec 07 '21 04:12 RealIndica

Hey, I've been stuck on this for quite a while. Its the connecting the the localhost:port part to actually view the video. I'm using Emgu.cv instead but it is mostly the same.

        private void videoListener()
        {
            _capture = new VideoCapture("http://127.0.0.1:27184", VideoCapture.API.Any); //FAILURE HERE
            _capture.ImageGrabbed += ProcessFrame;
            _capture.Set(Emgu.CV.CvEnum.CapProp.Fps, 60);
            _frame = new Mat();

            if (_capture != null)
            {
                try
                {
                    _capture.Start();
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message, Logger.LogType.Error);
                }
            }
        }

It breaks at that line and cannot figure out what to do with the data. However, looking at it in ncat, I can see plenty of data being streamed.

Do you have any idea what could be causing this? Been at it for nearly 6 hours and made no progress because of this.

This is my stream code :

        private void startClient()
        {
            byte[] bb1 = new byte[64];
            byte[] bb2 = new byte[4];
            byte[] bb3 = new byte[12];

            server = new TcpListener(localip, port);
            server1 = new TcpListener(localip, port1);

            server.Start();
            server1.Start();

            Logger.Log("Waiting for Stage 1", Logger.LogType.Message);
            client = server.AcceptTcpClient();
            if (client.Connected)
                Logger.Log("Stage 1 Completed");

            stream = client.GetStream();
            BufferedStream bf = new BufferedStream(stream);

            bf.Read(bb1, 0, bb1.Length);
            Logger.Log(Encoding.ASCII.GetString(bb1, 0, bb1.Length), Logger.LogType.Receive);
            bf.Read(bb2, 0, bb2.Length);
            Logger.Log(Encoding.ASCII.GetString(bb2, 0, bb2.Length), Logger.LogType.Receive);

            new Thread(() => { videoListener(); }).Start();
            
            Logger.Log("Waiting for Stage 2", Logger.LogType.Message);
            client1 = server1.AcceptTcpClient();
            if (client1.Connected)
                Logger.Log("Stage 2 Completed");

            stream1 = client1.GetStream();
            BufferedStream bf1 = new BufferedStream(stream1);
            bf.Read(bb3, 0, bb3.Length);
            Logger.Log("Stream Connected!", Logger.LogType.Message);
            try
            {
                while (bf.Read(bb3, 0, bb3.Length) > 0)
                {
                    bf.Flush();
                    bf1.Flush();
                    bf1.Write(bb3, 0, bb3.Length);
                }
            } catch (Exception) { Logger.Log("Stream Disconnected!", Logger.LogType.Error); }
        }

ADB Server Start Command :

CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 1.21 max_size=1024 bit_rate=8000000 max_fps=0 tunnel_forward=false control=false display_id=0 show_touches=false stay_awake=true

Hopefully, you can at least point me in the right direction.

Thank you.

dear try your ipv4 address of your machine assigned by LAN

qaisbayabani avatar Dec 08 '21 15:12 qaisbayabani

Hey, I've been stuck on this for quite a while. Its the connecting the the localhost:port part to actually view the video. I'm using Emgu.cv instead but it is mostly the same.

        private void videoListener()
        {
            _capture = new VideoCapture("http://127.0.0.1:27184", VideoCapture.API.Any); //FAILURE HERE
            _capture.ImageGrabbed += ProcessFrame;
            _capture.Set(Emgu.CV.CvEnum.CapProp.Fps, 60);
            _frame = new Mat();

            if (_capture != null)
            {
                try
                {
                    _capture.Start();
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message, Logger.LogType.Error);
                }
            }
        }

It breaks at that line and cannot figure out what to do with the data. However, looking at it in ncat, I can see plenty of data being streamed. Do you have any idea what could be causing this? Been at it for nearly 6 hours and made no progress because of this. This is my stream code :

        private void startClient()
        {
            byte[] bb1 = new byte[64];
            byte[] bb2 = new byte[4];
            byte[] bb3 = new byte[12];

            server = new TcpListener(localip, port);
            server1 = new TcpListener(localip, port1);

            server.Start();
            server1.Start();

            Logger.Log("Waiting for Stage 1", Logger.LogType.Message);
            client = server.AcceptTcpClient();
            if (client.Connected)
                Logger.Log("Stage 1 Completed");

            stream = client.GetStream();
            BufferedStream bf = new BufferedStream(stream);

            bf.Read(bb1, 0, bb1.Length);
            Logger.Log(Encoding.ASCII.GetString(bb1, 0, bb1.Length), Logger.LogType.Receive);
            bf.Read(bb2, 0, bb2.Length);
            Logger.Log(Encoding.ASCII.GetString(bb2, 0, bb2.Length), Logger.LogType.Receive);

            new Thread(() => { videoListener(); }).Start();
            
            Logger.Log("Waiting for Stage 2", Logger.LogType.Message);
            client1 = server1.AcceptTcpClient();
            if (client1.Connected)
                Logger.Log("Stage 2 Completed");

            stream1 = client1.GetStream();
            BufferedStream bf1 = new BufferedStream(stream1);
            bf.Read(bb3, 0, bb3.Length);
            Logger.Log("Stream Connected!", Logger.LogType.Message);
            try
            {
                while (bf.Read(bb3, 0, bb3.Length) > 0)
                {
                    bf.Flush();
                    bf1.Flush();
                    bf1.Write(bb3, 0, bb3.Length);
                }
            } catch (Exception) { Logger.Log("Stream Disconnected!", Logger.LogType.Error); }
        }

ADB Server Start Command :

CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 1.21 max_size=1024 bit_rate=8000000 max_fps=0 tunnel_forward=false control=false display_id=0 show_touches=false stay_awake=true

Hopefully, you can at least point me in the right direction. Thank you.

dear try your ipv4 address of your machine assigned by LAN

I figured it out. I needed to pipe the tcp data to an ffmpeg decoder to output bgra, then per frame write the data to a bitmap to display an image on my form.

RealIndica avatar Dec 08 '21 21:12 RealIndica

soon i b uploading an emgu solution 100% working face detection/recognition with a simple solution in C# Forms without consuming 100% of your CPU.

qaisbayabani avatar Dec 10 '21 18:12 qaisbayabani

Hey @RealIndica , would you be so kind to share your solution?

I'm still stuck on this problem.

Would be much appreciated.

SoareIL avatar Dec 29 '21 22:12 SoareIL

All issues resolved and new crispy version on its way even work well with bluestacks and no disconnection. and plz subscribe me to say thanks https://www.youtube.com/results?search_query=qaisbayabanni

qaisbayabani avatar Mar 04 '22 20:03 qaisbayabani

Hey, I've been stuck on this for quite a while. Its the connecting the the localhost:port part to actually view the video. I'm using Emgu.cv instead but it is mostly the same.

        private void videoListener()
        {
            _capture = new VideoCapture("http://127.0.0.1:27184", VideoCapture.API.Any); //FAILURE HERE
            _capture.ImageGrabbed += ProcessFrame;
            _capture.Set(Emgu.CV.CvEnum.CapProp.Fps, 60);
            _frame = new Mat();

            if (_capture != null)
            {
                try
                {
                    _capture.Start();
                }
                catch (Exception ex)
                {
                    Logger.Log(ex.Message, Logger.LogType.Error);
                }
            }
        }

It breaks at that line and cannot figure out what to do with the data. However, looking at it in ncat, I can see plenty of data being streamed. Do you have any idea what could be causing this? Been at it for nearly 6 hours and made no progress because of this. This is my stream code :

        private void startClient()
        {
            byte[] bb1 = new byte[64];
            byte[] bb2 = new byte[4];
            byte[] bb3 = new byte[12];

            server = new TcpListener(localip, port);
            server1 = new TcpListener(localip, port1);

            server.Start();
            server1.Start();

            Logger.Log("Waiting for Stage 1", Logger.LogType.Message);
            client = server.AcceptTcpClient();
            if (client.Connected)
                Logger.Log("Stage 1 Completed");

            stream = client.GetStream();
            BufferedStream bf = new BufferedStream(stream);

            bf.Read(bb1, 0, bb1.Length);
            Logger.Log(Encoding.ASCII.GetString(bb1, 0, bb1.Length), Logger.LogType.Receive);
            bf.Read(bb2, 0, bb2.Length);
            Logger.Log(Encoding.ASCII.GetString(bb2, 0, bb2.Length), Logger.LogType.Receive);

            new Thread(() => { videoListener(); }).Start();
            
            Logger.Log("Waiting for Stage 2", Logger.LogType.Message);
            client1 = server1.AcceptTcpClient();
            if (client1.Connected)
                Logger.Log("Stage 2 Completed");

            stream1 = client1.GetStream();
            BufferedStream bf1 = new BufferedStream(stream1);
            bf.Read(bb3, 0, bb3.Length);
            Logger.Log("Stream Connected!", Logger.LogType.Message);
            try
            {
                while (bf.Read(bb3, 0, bb3.Length) > 0)
                {
                    bf.Flush();
                    bf1.Flush();
                    bf1.Write(bb3, 0, bb3.Length);
                }
            } catch (Exception) { Logger.Log("Stream Disconnected!", Logger.LogType.Error); }
        }

ADB Server Start Command :

CLASSPATH=/data/local/tmp/scrcpy-server.jar app_process / com.genymobile.scrcpy.Server 1.21 max_size=1024 bit_rate=8000000 max_fps=0 tunnel_forward=false control=false display_id=0 show_touches=false stay_awake=true

Hopefully, you can at least point me in the right direction. Thank you.

dear try your ipv4 address of your machine assigned by LAN

I figured it out. I needed to pipe the tcp data to an ffmpeg decoder to output bgra, then per frame write the data to a bitmap to display an image on my form.

forget it man Emgu/Vlc or any other decoder is not efficient enough to decode the stream and show you the pic. you can still do it with opencv face recognition etc or use android device side face recog and you must try my server i just uploaded that is a single file programmed in Android Studio not a junk of classes like scrcpy to just stream and a flawless client as promised by me. new client works like a charm and any one would love to have it.

qaisbayabani avatar Mar 22 '22 10:03 qaisbayabani

Hello, can I get some help? I don't know what ip should I put in adb connect. I'm just plugging in the device using USB and I have USB debugging enabled. When I run it gives me this:

Entered in 2nd thread
Waiting for a connection Server No.1----------
cannot connect to 192.168.0.2:5555: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (10060)

 scrcpy-server: 1 file pushed, 0 skipped. 88.5 MB/s (37330 bytes in 0.000s)

 java.io.IOException: Address already in use
        at android.net.LocalSocketImpl.bindLocal(Native Method)
        at android.net.LocalSocketImpl.bind(LocalSocketImpl.java:278)
        at android.net.LocalServerSocket.<init>(LocalServerSocket.java:49)
        at com.genymobile.scrcpy.DesktopConnection.open(DesktopConnection.java:48)
        at com.genymobile.scrcpy.Server.scrcpy(Server.java:57)
        at com.genymobile.scrcpy.Server.main(Server.java:255)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:463)

 [server] INFO: Device: Xiaomi M2102J20SG (Android 11)

 [server] ERROR: Exception on thread Thread[main,5,main]

Since I don't plan to connect wirelessly to the device I deleted the adb connect process.

Address already in use was solved by modifying the arguments when starting scrcpy-server. More specifically the forward or reverse mode argument: server->tunnel_forward ? "true" : "false"

My arguments as of this moment look like this:

ps.Arguments = "shell " + "CLASSPATH=/data/local/tmp/scrcpy-server.jar " +
                                "app_process " + "/ " + "com.genymobile.scrcpy.Server " +
                                "1.19 " +    //SCRCPY_VERSION
                                "info " +    //log_level_to_server_string(params->log_level)
                                "1024 " +    //max_size_string
                                "8000000 " + //bit_rate_string (8MB)
                                "0 " +       //max_fps_string (adaptive)
                                "-1 " +      //lock_video_orientation_string
                                "false " +   //server->tunnel_forward ? "true" : "false" (false for reverse mode)
                                "- " +       //params->crop ? params->crop : "-"
                                "false " +    //"true", // always send frame meta (packet boundaries + timestamp)
                                "false " +   //params->control ? "true" : "false"
                                "0 " +       //display_id_string
                                "false " +   //params->show_touches ? "true" : "false"
                                "true " +    //params->stay_awake ? "true" : "false"
                                "- " +       //params->codec_options ? params->codec_options : "-"
                                "- " +       //params->encoder_name ? params->encoder_name : "-"
                                "false";     //params->power_off_on_close ? "true" : "false"

Now my problem is getting Empty outputs from the device after this exception:

Third is Gneeal :
System.IO.IOException: Unable to write data to the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Write(Byte[] buffer, Int32 offset, Int32 size)
   at System.IO.BufferedStream.FlushWrite()
   at System.IO.BufferedStream.Flush()
   at Program.ForFun.Fun() in C:\Users\soare\source\repos\cs_scrcpy\cs_scrcpy\Program.cs:line 254

use my client and server just uploaded. its without adb commands.

qaisbayabani avatar Mar 22 '22 10:03 qaisbayabani

why still print Empty in windows console ? image.Empty() return true ? why? change your IP addresses according to your own network environment

my device is Samsung S6 ,do the flowing things make it correct. 1.change http://127.0.0.1:27184 to tcp://127.0.0.1:27184 2.upgrade 1.12.1 to 1.13

this program make me understand the scrcpy basic protocol , shown me a direction to diving in scrcpy source code.

Thanks so much.

you must have my own server a single .java file to do all the magic and new client flawlessly working. as go to my readme

qaisbayabani avatar Mar 22 '22 10:03 qaisbayabani

UPDATED STABLIZED AND NEW SERVER AND CLIENT WITHOUT ADB AND EVEN ON INTERNET

qaisbayabani avatar May 15 '23 14:05 qaisbayabani