Search code examples
androidsql-serverudpsql-server-express

Default location for data packets sent over UDP to SQL Express


I have created an Android application that has two input fields and a verify button. I want to send information to a SQL Express server that is on my Windows desktop over UDP connection. I have tested the connection with a utility and it works perfect but when I connect to the server, I don't know where the default location is for the information to be stored. Can anyone please help me? Below is the UDP connection code.

int port = 48569;
                        try {
                            DatagramSocket s = new DatagramSocket();
                            InetAddress local = InetAddress.getByName("10.3.22.218");
                            int msg_length = msg.length();
                            byte[] message = msg.getBytes();
                            DatagramPacket p = new DatagramPacket(message, msg_length, local, port);
                            s.send(p);
                        }catch (SocketException e) {
                            e.printStackTrace();
                        }catch (UnknownHostException e) {
                            e.printStackTrace();
                        }catch(IOException e) {
                            e.printStackTrace();
                        }

Solution

  • SQL Server on your desktop does not listen for UDP packets. Information sent with these packages will not be stored anywhere. To connect to SQL Server you will need a client (ADO.NET). Sending packages over the wire will not work. And why UDP? How you will get back the result from the "verification"? And I believe connecting directly from your mobile app to the SQL Server is not the best option. You should either create some service layer over your database (for example WCF service) and use this API from your mobile app, or go further and look for Azure Mobile App Service or something similar.