Code:
on 1:SOCKWRITE:mysocket: {
  if ($sockerr) /echo -a Error
  else {
    ; .yourcodehere

    ...

     if ($isfile(data.txt)) .remove data.txt
  }
}

on 1:SOCKREAD:mycoket: {
  /sockread -f &data
  /bwrite data.txt -1 -1 &data
}

on 1:SOCKCLOSE:mysocket: {
  /bread data.txt 0 $file(data.txt).size &data
  .remove data.txt

  ...

  ; parse the file here, do what youw ant with it.  The whole packet is now in the &data binvar
} 


-KingTomato