Top Mud Sites Forum Return to TopMudSites.com
Go Back   Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Click here to Register

Reply
 
Thread Tools
Old 04-18-2019, 07:14 PM   #1
ThunderZ
New Member
 
Join Date: Feb 2013
Posts: 5
ThunderZ is on a distinguished road
Issue collecting input from blowtorch

I recently added Kavir's protocol handler to my MUD (based on SocketMUD) and for some odd reason ALL other clients work perfectly fine...except for BlowTorch(Android MUD client).

I can't figure out why but when you try to input anything into the mud from Blowtorch..Blowtorch ****s itself...freezes and eventually crashes and the phone must be rebooted or force close blowtorch.

From what I can tell it from the read_from_socket() function

Code:
bool read_from_socket(descriptor_t *dsock)
{
  int size;
  extern int errno;
  static char read_buf[MAX_PROTOCOL_BUFFER];
  read_buf[0] = '\0';

  /* check for buffer overflows, and drop connection in that case */
  size = 0;
  if (strlen(dsock->inbuf) >= sizeof(dsock->inbuf) - 10)
  {
    text_to_socket(dsock, "\n\r!!!! Input Overflow !!!!\n\r");
    return FALSE;
  }

  /* start reading from the socket */
  for (;;)
  {
    int sInput;

    sInput = read(dsock->control, read_buf + size,sizeof(read_buf) - 10 - size );

    if (sInput > 0)
    {
      size += sInput;

      if (read_buf[size-1] == '\n' || read_buf[size-1] == '\r')
        break;
    }
    else if (sInput == 0)
    {
      log_string("Read_from_socket: EOF");
      return FALSE;
    }
    else if (errno == EAGAIN)
      break;
    else
    {
      perror("Read_from_socket");
      return FALSE;
    }     
  }
  read_buf[size] = '\0';
  ProtocolInput( dsock, read_buf, size, dsock->inbuf );
  return TRUE;
}
What am I doing wrong? Help PLEASE! lol.

Edit: Specifically it seems to be an issue with the way im calling read() I think..

Code:
sInput = read(dsock->control, read_buf + size,sizeof(read_buf) - 10 - size );

Last edited by ThunderZ : 04-18-2019 at 07:18 PM. Reason: edit
ThunderZ is offline   Reply With Quote
Old 05-07-2020, 02:59 PM   #2
Istarian
New Member
 
Join Date: May 2015
Posts: 3
Istarian is on a distinguished road
Re: Issue collecting input from blowtorch

How do you figure it's an error reading from the socket? Are you seeing that log string or perror call in a way that is unambiguously from the specific connection/socket that the Android (Blowtorch) client is connected to?

Tangentially, if you don't know why there's an absolute adjustment of 10 bytes you might want to figure that out.

https://en.wikipedia.org/wiki/Read_(...l)#POSIX_usage
http://man7.org/linux/man-pages/man2/read.2.html

http://man7.org/linux/man-pages/man2/pwrite.2.html
https://pubs.opengroup.org/onlinepub.../unistd.h.html

Looks like you're actually using pread from unistd.h based on the format... or maybe it's the read POSIX call...

Code:
sInput = read(dsock->control, read_buf + size,sizeof(read_buf) - 10 - size );
Presumably you're trying to read one byte at a time from the network socket into read_buf until you hit the end of a line and tracking total read bytes insize. Based on the pread documentation it looks like the second parameter should be a fixed number of bytes to read from the offset on... So I'm not sure what 'read_buf + size' is supposed to be; is it really supposed to change with the size and what value do you imagine 'read_buf' to have?

If it's the POSIX read call you mean I think maybe it should be:

Code:
sInput = read(dsock->control, &(read_buf + size), sizeof(read_buf) - 10 - size );
because that second parameter is supposed to be a pointer to the buffer... My C is probably rusty though and pointer arithmetic..

Last edited by Istarian : 05-07-2020 at 03:05 PM.
Istarian is offline   Reply With Quote
Reply


Thread Tools


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -4. The time now is 05:59 AM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Style based on a design by Essilor
Copyright Top Mud Sites.com 2014