Getting 8 nulls in response to login

I am currently writing a twitch program in Java.

    socket = new Socket(SERVER, TWITCH_PORT);
    is = socket.getInputStream();
    os = socket.getOutputStream();
    inputStreamReader = new InputStreamReader(is, "UTF-8");
    outputStreamWriter = new OutputStreamWriter(os, "UTF-8");
    
    BufferedReader read = new BufferedReader(inputStreamReader);
    BufferedWriter writer = new BufferedWriter(outputStreamWriter);

    writer.write("PASS oauth:" + OAUTH);
    writer.flush();
    writer.write("NICK " + NICK);
    writer.flush();

    while(true) {
        String line = read.readLine();
        if(line != null) {
            System.out.println(read.readLine());
        }
    }

The program connects and then continues to receive a infinite amount of null responses. I am not sure what I did wrong? As the twitch API says I should recieve:

:tmi.twitch.tv 001 twitch_username :connected to TMI
:tmi.twitch.tv 002 twitch_username :your host is TMI
:tmi.twitch.tv 003 twitch_username :this server is pretty new
:tmi.twitch.tv 004 twitch_username tmi.twitch.tv 0.0.1 w n
:tmi.twitch.tv 375 twitch_username :- tmi.twitch.tv Message of the day -
:tmi.twitch.tv 372 twitch_username :- not much to say here
:tmi.twitch.tv 376 twitch_username :End of /MOTD command

Thanks

Each IRC line/command must must end with an ASCII carriage return and linefeed (\r\n). Try fixing that and see if there is any change.

Thanks man that worked. Getting a error logging in response now though

Edit: nevermind fixed it thanks for the help!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.