Skip to content

Commit

Permalink
Check if connection is available
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Downarowicz committed Mar 15, 2022
1 parent 51d8c4d commit c2af272
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions src/main/java/at/downardo/j3270Server/Telnet.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,44 +139,44 @@ public static int[] TelnetRead(BufferedInputStream in, int[] buf) throws IOExcep
int state = NORMAL;
int n = 0;
while(n <= (buf.length-1)) {
int bufRead = in.read();



if(bufRead == 0) {
continue;
}


switch(state) {
case NORMAL:
if(bufRead == IAC) {
state = COMMAND;
}else {
buf[n] = bufRead;
n++;
if(in.available() > 0) {
int bufRead = in.read();

if(bufRead == 0) {
continue;
}
break;
case COMMAND:
if(bufRead == 0xff) {
buf[n] = 0xff;


switch(state) {
case NORMAL:
if(bufRead == IAC) {
state = COMMAND;
}else {
buf[n] = bufRead;
n++;
}
break;
case COMMAND:
if(bufRead == 0xff) {
buf[n] = 0xff;

n++;
state = NORMAL;
}else if(bufRead == SB) {
state = SUBNEG;
}else {
state = NORMAL;
}
break;
case SUBNEG:
if(bufRead == SE) {
state = NORMAL;
}else {
//remain in subnegotiation consumin bytes until we get SE
}
break;

n++;
state = NORMAL;
}else if(bufRead == SB) {
state = SUBNEG;
}else {
state = NORMAL;
}
break;
case SUBNEG:
if(bufRead == SE) {
state = NORMAL;
}else {
//remain in subnegotiation consumin bytes until we get SE
}
break;

}

}
Expand Down

0 comments on commit c2af272

Please sign in to comment.