[Gambas-user] IRC, telnet etc
pezz
perrymou at ...370...
Sun Feb 29 22:26:05 CET 2004
>Well, to find a complete line wasting less resources, you could use
>Peek() method, which reads data from socket, but keeping it in the
>buffer for the next time:
>
>PUBLIC SUB MySock_Read()
>
> DIM S As String
> IF MySock.Status=Net.Connected THEN
> S=MySock.Peek() ' We read current buffer
> ' If there's a carry return...
> IF INSTR(S,Chr(13)) or INSTR(S,Chr(10)) THEN
> ' we read just the line, keeping the
> ' rest in the buffer
> LINE INPUT #MySock,S
> getline(S)
> ' you don't have to test Chr(13) again
> ' in getline()
> END IF
> END IF
>END
>
>You could also add a routine to test the lenght of the buffer, to
>discard it if it is too long (to prevent your program of beeing crashed
>by a malicious IRC hacker, for instance)
>
>Regards,
>
>Daniel Campos
That's neat Daniel, thanks. Idea: Gambas channel on IRC?
pezz
More information about the User
mailing list