This Code For Initialize Socket Server on emulator android but Cann't Transfer Data and Get in Logcat of eclipse warning exception "java.net.BindException: bind failed: EADDRNOTAVAIL (Cannot assign requested address) "

ServerSocket serversock=new ServerSocket(); 
DataInputStream  Input_Data_Stream=null;                  
InetAddress address1 =InetAddress.getByName("10.0.0.1");
InetSocketAddress g =new InetSocketAddress(address1, 8080);
serversock.bind(g);
Socket Client_Socket=serversock.accept();  
Input_Data_Stream=new DataInputStream(Client_Socket.getInputStream());
String message=Input_Data_Stream.readUTF();
 Log.d("Message", message);

	

This in other Way snippet code socket server and have same exception

java.net.BindException: Socket is already bound

serversock=new ServerSocket();
serversock.bind(new InetSocketAddress("10.0.0.1", 8080));

This Code I did not get on Previous Exception but when Execute "serversock.accept();" for Start Listen on PORT I got Error exception and if use a different iP address "127.0.0.1" Will got on warnnig exception "java.net.BindException: bind failed: EADDRNOTAVAIL (Cannot assign requested address)"

SocketAddress Address= new InetSocketAddress("127.0.0.1", 8080);
serversock=new ServerSocket();
serversock.bind(Address);

This Code Socket Client

Socket Socket1 =null;
DataOutputStream Output_Data_stream=null;
try
{
Socket1=  new Socket("127.0.0.1", 8080);
Output_Data_stream=new DataOutputStream(Socket1.getOutputStream());
Output_Data_stream.writeUTF("Welcome");
Output_Data_stream.close();
}
catch (UnknownHostException e)
				{
					e.printStackTrace();
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}

This question already has an answer here:

I have an app which listens for a socket connection, and then uses DispatchSource.makeReadSource to read from the socket. This bit is working great:

let mySocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)
// bind(...)
listen(newSocket, 1)

let clientSocket = accept(...)

let clientListener = DispatchSource.makeReadSource(
    fileDescriptor: clientSocket, 
    queue: DispatchQueue.main)
clientListener.setEventHandler {
    // Called when data is available, and I can read it without problem
}

My problem is while the dispatch source is waiting for data from the client, if I deploy my app (or stop my app) using Xcode, somehow the socket remains open and I cannot setup my socket again. When I call bind it returns -1

I have to restart my device for the socket to be released again

I've tried cleaning up my sockets when the app is closed, but I can't seem to detect when Xcode kills my app:

  • applicationWillTerminate is not called in my app delegate
  • deinit isn't called in any of my classes
  • none of the life cycle methods are called in my view controller

I'm not sure how the socket is remaining open as I would assume iOS would kill of all the resources when it killed the app

Is there a way to stop the dispatcher from holding on to the socket?

After seeing several posts about this error, I don't really understand why the sometimes I am getting this exception

I saw several posts here that suggested to do a loop over binding the socket, but I think it should be executed once and there is a problem somewhere else

this is my code:

 public ServerNetworkThread()
    {
        setName("ServerNetworkThread");
        _port = Logics.getInstance().getSharedPrefsManager().getInt(SharedPreferencesManager.SERVER_PORT_KEY, Consts.SERVER_PORT);
    }

    public void setHandler(Handler h)
    {
        _handler = h;
    }

    @Override
    public void run()
    {

        _isWorking = true;
        try
        {
            _serverSocket = new ServerSocket();
            _serverSocket.setReuseAddress(true);
            _serverSocket.bind(new InetSocketAddress(_port));

            while (_isWorking)
            {
                _socket = _serverSocket.accept();
                _socket.setSoTimeout(Consts.CLIENT_SOCKET_TIMEOUT);
                readDataTest();
            }

        }
        catch (SocketTimeoutException e)
        {
            e.printStackTrace();
            Logger.d("anton", e.getMessage());
        }
        catch (IOException e)
        {
            e.printStackTrace();
            Logger.d("anton", "server thread IOException" + e.getMessage());
        }

    }

    private void readDataTest() throws IOException
    {
        //          BufferedReader inFromClient = new BufferedReader(new InputStreamReader(_socket.getInputStream(),Charset.forName("UTF-16LE")));
         //          BufferedReader inFromClient = new BufferedReader(new InputStreamReader(_socket.getInputStream(),Charset.forName("UTF-16LE")));
        InputStream iStream = _socket.getInputStream();
        InputStreamReader in = new InputStreamReader(iStream, Charset.forName("UTF-16LE"));
        DataOutputStream outToClient = new DataOutputStream(_socket.getOutputStream());
        char[] buf = new char[1024];
        int lettersCount = in.read(buf, 0, buf.length);
        String request = new String(buf,0,lettersCount);
//      request = request.split(Consts.EOF)[0];
        Log.d("test","server got request="+request);

        String responseStr = parseResponse(request);
        byte[] response = responseStr.getBytes("UTF-16LE");
        outToClient.write(response);
        outToClient.flush();
        outToClient.close();
        in.close();
        _socket.close();
    }

this is my exception:

W/System.err( 1433): java.net.BindException: bind failed: EADDRINUSE (Address already in use)

W/System.err( 1433): at libcore.io.IoBridge.bind(IoBridge.java:89)

W/System.err( 1433): at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:150)

W/System.err( 1433): at java.net.ServerSocket.bind(ServerSocket.java:319)

W/System.err( 1433): at java.net.ServerSocket.bind(ServerSocket.java:282)

W/System.err( 1433): at com.example.visionixpanel.logics.network.ServerNetworkThread.run(ServerNetworkThread.java:61)

W/System.err( 1433): Caused by: libcore.io.ErrnoException: bind failed: EADDRINUSE (Address already in use)

W/System.err( 1433): at libcore.io.Posix.bind(Native Method)

W/System.err( 1433): at libcore.io.ForwardingOs.bind(ForwardingOs.java:40)

W/System.err( 1433): at libcore.io.IoBridge.bind(IoBridge.java:87)

W/System.err( 1433): ... 4 more

it is something to do with this line:

 _serverSocket.bind(new InetSocketAddress(_port));

java.net.BindException: Address already in use: JVM_Bind at java.net.TwoStacksPlainSocketImpl.socketBind(Native Method) at java.net.TwoStacksPlainSocketImpl.socketBind(TwoStacksPlainSocketImpl.java:137) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:387) at java.net.TwoStacksPlainSocketImpl.bind(TwoStacksPlainSocketImpl.java:110) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:190) at java.net.ServerSocket.bind(ServerSocket.java:375) at io.netty.channel.socket.oio.OioServerSocketChannel.doBind(OioServerSocketChannel.java:140) at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:554) at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1258) at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501) at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486) at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:980) at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:250) at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:365) at io.netty.channel.ThreadPerChannelEventLoop.run(ThreadPerChannelEventLoop.java:67) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858) at java.lang.Thread.run(Thread.java:745)

I am deploying 3 different aps.net web forms applications on a VM server. The customer has installed the certificate on the server. And the IT tells me to bind each application to a different IP address. I created 3 web sites (pointing each to a different physical folder). But when I bind each site (in IIS) the IP address pull-down shows only one IP address (and All Unassigned). How would I bind 2 other sites to different IP addresses?

I am trying to run NodeJs file using Visual studio but it is showing me error annot find 'ripple-lib' and this folder is already existed in NodeJs i just drag and dropped this folder to project and when i am running this file using F5 this is showing me error and if i am running this file using command prompt it is running successfully.

below is my compleate source code of Node.js

'use strict';
const RippleAPI = require('ripple-lib').RippleAPI; // require('ripple-lib')

const address = 'rJdqcGV4eytsm4CMpJ8gJ9RdDZnSPoL5Be'; //Test Address
const secret = 'ssX5xpgiFB5ug2birYcU4sXBEe2cx';    // Test Address


const api = new RippleAPI({server: 'wss://s.altnet.rippletest.net:51233'});



const instructions = {maxLedgerVersionOffset: 5};

const payment = {
source: {
 address: address,
maxAmount: {
  value: '0.01',
  currency: 'XRP'
}
},
destination: {
address: 'rfH1Ca3NXSLXNBxKrgYUaAbArijUrMsxrZ',
tag: 8779,
amount: {
  value: '50',
  currency: 'XRP'
 }
}
};
function quit(message) {
console.log(message);
process.exit(0);

}

function fail(message) {
console.error(message);
process.exit(1);

}

api.connect().then(() => {
console.log('Connected...');
return api.preparePayment(address, payment, instructions).then(prepared => {
console.log('Payment transaction prepared...');
const {signedTransaction} = api.sign(prepared.txJSON, secret);
console.log('Payment transaction signed...');
api.submit(signedTransaction).then(quit, fail);

});

 }).catch(fail);

I have 2 dual-h bridge controllers(used to supple power to fans) that are connected to my raspberry pi 3 b via GPIO and a battery for power I have created a script in python 3 that uses Bluetooth classic to ask the connected phone in a terminal how long the fan should be on for and how long they should be off for in a loop I have got this to work GREAT, but this works only on android as it is Bluetooth classic i now want to make this work for my iPhone as well i found out i would need to use BLE so my question is how can i convert my original script in Bluetooth classic(using RF COMM Sockets) to use Bluetooth Low Energy.

Here is my original script

# Importing the Bluetooth Socket library
import bluetooth
# Importing the GPIO library to use the GPIO pins of Raspberry pi
import RPi.GPIO as GPIO
import time

fan_pin = 16# Initializing pin 16 for fan
fan2_pin = 18
GPIO.setmode(GPIO.BOARD)    # Using BCM numbering
GPIO.setup(fan_pin, GPIO.OUT)   # Declaring the pin 16 as output pin
GPIO.setup(fan2_pin, GPIO.OUT)  # Declaring the pin 16 as output pin

host = ""
port = 1    # Raspberry Pi uses port 1 for Bluetooth Communication

# Creaitng Socket Bluetooth RFCOMM communication
server = bluetooth.BluetoothSocket(bluetooth.RFCOMM)
print('Bluetooth Socket Created')

try:
    server.bind((host, port))
    print("Bluetooth Binding Completed")
except:
    print("Bluetooth Binding Failed")

server.listen(1) # One connection at a time
# Server accepts the clients request and assigns a mac address. 
client, address = server.accept()
print("Connected To", address)
print("Client:", client)
while 1:


    # Receivng the data. 
    client.send("How long do you want the fans to be on for?/n")
    On = int(client.recv(1024)) # 1024 is the buffer size.
    time.sleep(5)
    client.send("Ok, Now how long do you want the fans to be off for?/n")
    Off = int(client.recv(1024))
    print(On)
    print(Off)
    while True:
        GPIO.output(fan_pin, GPIO.HIGH)
        GPIO.output(fan2_pin, GPIO.HIGH)
        time.sleep(On)
        GPIO.output(fan_pin, GPIO.LOW)
        GPIO.output(fan2_pin, GPIO.LOW)
        time.sleep(Off)



# Making all the output pins LOW
GPIO.cleanup()
# Closing the client and server connection
client.close()
server.close()

I would imagine this would be as simple as changing anything that was Bluetooth classic code to BLE code. Max like 20 lines to change? Thanks in advance for anyone who helps!

I am reading about socket programming and got to know that ip is assigned to socket with bind() call before connection to server.Is my thinking of binding address means to bind any ip address correct.

This question already has an answer here:

I am Trying to validate email address field using below regex

    + (BOOL) isValidEmail:(NSString *)email
{
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [emailTest evaluateWithObject:email];
}

But its getting failed for validating below cases.

i) test@-gmail.com

ii) test..test@gmail.com

iii) .test@gmail.com

iv) test.@gmail.com

Please suggest me what modification do I need for considering these cases.

I'm setting up a nodejs server. i made json array parser using swift but json data is array from nodejs server. i know json dictionary type parsing. i have type casting problem what can i do ?

json array type casting as? [[string:anyobject]] i've already tried . There are still exist problem. example, i can see nil, error (dictionary always fail) my server -> nodejs , redis

do{

            let json = try! JSONSerialization.jsonObject(with: data, options: []) as? NSArray

            print("jsonserial = \(json!)")




            self.event = [Module]()

            for dict in json as? [string:Anyobject]{

                let events = Module()
                print("check=\(dict!)")

                events.dateOfevent = dict!["datetime"] as? String
                events.restaurantAddr = dict!["address"] as? String
               events.latpin = dict!["lat"] as? String
                events.longpin = dict!["long"] as? String
                events.citystate  = dict!["citystate"] as? String
                events.userid = dict!["userid"] as? String


                self.event?.append(events)
             */


               // print(self.finalArray)
            DispatchQueue.main.async {

                self.collectionview_events?.reloadData()



            }


        } catch let jsonError{
            print(jsonError)
        }

json array type casting as? [[string:anyobject]] i've already tried . There are still exist problem. example, i can see nil, error (dictionary always fail)

->json data (get from url)

["{\"address\":\"Second St,Davis,CA\",\"citystate\":\"Davis,CA\",\"lat\":\"38.54369\",\"long\":\"-121.7395931\",\"datetime\":\"09:42 16/02/2019\",\"userid\":\"lll\"}","{\"address\":\"Universal City Plaza,Los Angeles,CA\",\"citystate\":\"Los Angeles,CA\",\"lat\":\"34.13708590566492\",\"long\":\"-118.355171084404\",\"datetime\":\"03:37 14/02/2019\",\"userid\":\"lll\"}","{\"address\":\"N Harbor Dr,San Diego,CA\",\"citystate\":\"San Diego,CA\",\"lat\":\"32.732373382591\",\"long\":\"-117.1975028514862\",\"datetime\":\"08:27 15/02/2019\",\"userid\":\"lll\"}"]

I'm working on a webpage that requires you to input the address and contact information of a related party, up to three related parties. I'm doing this by putting the controls needed into a Repeater inside of an UpdatePanel, and then setting the Repeater datasource to a dummy array of integers on button click - this allows me to control how many times it repeats, and it works excellently.

However, when the user has already input some information and decides they need an additional row, it overwrites everything they've already written, due to it binding from a blank datasource. I've seen a few solutions where they put the data from the controls into a dictionary/list/similar object at postback, update the repeater, and then put them back in, but I'd like to avoid that if possible (which it probably isn't), as there's about a dozen fields per repeater row.

So, my question is how can I add a new row to this repeater without reloading the previous rows? Is it possible?

Using ASP.Net with a VB.Net codebehind, focused on working in IE.