How do I get a socket connection more than once?

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

clplaneguy
Novice
Posts: 29
Joined: Sat Feb 18, 2017 3:44 pm

How do I get a socket connection more than once?

Postby clplaneguy » Tue May 15, 2018 8:03 pm

I am in the process of reproducing the “openCV web streaming” project from leJOS News. I have done so and it worked. Now, I am running the code again and cannot get a socket connection. I have gutted the code down to a minimum to test only the socket connection. I have again followed the hints that got the project to work for me in the first place. The test code did work once and only once. I am incrementing PORT to avoid “Port busy”.

Firewall is off.
PC IP address is 192.168.0.2 Correct
PORT 192.168.0.2:8080


My test code follows . . .

Does anyone know what I may have done that is preventing the socket connection?


EV3 code

Code: Select all

import java.net.ServerSocket;                           
import java.net.Socket;                             
                                                     
import org.opencv.core.Core;                       
                                                               
                                                                     
public class SocketTEST {    //////////////////////////////////////////////////////
                                                                                 //
    public static void main(String[] args) throws Exception                      //
        {    ////////////////////////////////////////////////////////////////    //
        System.out.println();                                              //    //
        System.out.println("5/15/2018");                                   //    //
        System.out.println("Program: SocketTEST");                         //    //
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);                      //    //
                                                                           //    //
        System.out.println("Point 1");                                     //    //
        ServerSocket ss = new ServerSocket(8080);   //    8080             //    //
        System.out.println("Connection to socket 8080\nWaiting . . .");    //    //
        Socket sock = ss.accept();                                         //    //
        System.out.println("Socket connected");                            //    //
        sock.close();                                                      //    //
        ss.close();                                                        //    //
        }    ////////////////////////////////////////////////////////////////    //
                                                                                 //
 }    /////////////////////////////////////////////////////////////////////////////



PC code

Code: Select all

<html>
<head>
<title>logitech</title>
</head>
<body>

Port <b>8080</b>
<img src="http://192.168.0.2:8080" width=50% height=50%>
</body>
</html>

clplaneguy
Novice
Posts: 29
Joined: Sat Feb 18, 2017 3:44 pm

Solved!! How do I get a socket connection more than once?

Postby clplaneguy » Wed May 16, 2018 4:31 pm

SOLVED

The IP Address of both my PC and EV3 have, for some unknown reason, changed. My current PC IP address is now 192.168.0.2! My current EV3 IP address is now 192.168.0.5!

The image is NOT being served by the PC at 192.168.0.2:8080 !

It is actually being served by the EV3 at 192.168.0.5:8080 !

floydbloke
Novice
Posts: 42
Joined: Mon Nov 04, 2013 7:04 pm

Re: How do I get a socket connection more than once?

Postby floydbloke » Wed May 16, 2018 10:43 pm

Could it be that your router is also your DHCP server and when you restart your PC and/or EV3 their original IP addresses have been assigned to other devices?

My main desktop PC has a static IP address and I have reserved an IP address (by 'tying it' to the MAC address of the WiFi adapter) for my EV3's to prevent this exact sort thing from happening.


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 2 guests