mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2004
Posts: 111
Z
Zeusbwr Offline OP
Vogon poet
OP Offline
Vogon poet
Z
Joined: Mar 2004
Posts: 111
Well i am sending data from a 3rd party application and recieving it with the following code

Code:
on *:sockread:_server: {
  if ( $sockerr ) {
    return
  }
  sockread %data
  echo -s (Server %data )
  unset %data
}
 


Now for some reason, the variable %data is blank.

I've been whackin away at it, but i cannot get it to recieve the data...

Can anyone tell me what encoding mIRC uses? im sending it in a C# Application so maybe its the wrong encoding.. but i've tried all the major ones..

I dunno, i dont have problems sending it to other programs.. but when i set this up, mirc see's the event, but not the data..

Any help?

(for fun, heres the snipplet of C# data too )
Code:
 			byte[] byteSendData = Encoding.ASCII.GetBytes( sData.ToCharArray() );
			this.socketClient.Send( byteSendData ); 

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Not really sure if it will help you, but have you looked into socklisten?


Invision Support
#Invision on irc.irchighway.net
Joined: Mar 2004
Posts: 111
Z
Zeusbwr Offline OP
Vogon poet
OP Offline
Vogon poet
Z
Joined: Mar 2004
Posts: 111
Ok, well i might have found something.. to go somewhere atleast.

Notice in the C# code that it splits the string into an Array for each character.

Now with the -f Flag on sockread i get the 1st character of the string i am sending..

i've been away so long from mIRC im kinda lost. Can mIRC even hold arrays? Is it possible that "data" is an array? Heres an updated look at my mIRC code, and its output.

Code:
on *:sockread:_server: {
  if ( $sockerr ) {
    return
  }
  sockread -f %data
  echo -s (Server) ( $+ %data $+ )
  unset %data
}
 


Quote:
(Server) (r)


thats after sending the following string (before its chopped into the array)

Quote:
richTextBox4




*edit*
Whoa.. Interesting turn of events. It apears the message is stored in in mIRC buffer or something. Note my repeated attempts. I changed the message and noticed it wasent the right character. Take note at what it is spelling.

Quote:

(Server) (r)
(Server) ()
(Server) ()
(Server) (h)
(Server) (T)
(Server) (e)
(Server) (x)
(Server) (t)
(Server) (B)


( the two blank spots i was trying to get an array to work )

Is there a way to flush the buffer into a string?

Last edited by Zeusbwr; 13/09/05 08:23 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Quote:
Note: A single /sockread may not be enough to read the entire buffer. You should keep reading until $sockbr (bytes read) is set to zero. This is far faster than letting mIRC re-trigger the event. If your script doesn't read the whole buffer, the on sockread event is re-triggered if:
a) you were reading into a &binvar.
b) you were reading into a %var and there is still a $crlf terminated line in the buffer waiting to be read.


From that (in the help file), I'd say that you have no $crlf in your received text, so it's stopping. You could get around that by adding a $crlf if possible, or reading into a &binvar. Or, you can try something like this (which, from what the help file quote says [above], would probably be faster, anyhow):

Code:
on *:sockread:_server: {
  if ( $sockerr ) {
    return
  }
  var %data
  while ($sockbr != 0) {
    sockread %data
    echo -s (Server) ( $+ %data $+ )
  }
}


If you need to combine the text into one line, you can do this:

Code:
on *:sockread:_server: {
  if ( $sockerr ) {
    return
  }
  var %data
  while ($sockbr != 0) {
    sockread %data
    var %output = %output $+ %data
  }
  echo -s (Server) ( $+ %output $+ )
}

Last edited by Riamus2; 13/09/05 08:41 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Mar 2004
Posts: 111
Z
Zeusbwr Offline OP
Vogon poet
OP Offline
Vogon poet
Z
Joined: Mar 2004
Posts: 111
i dunno. All i know is its in the buffer. Take a look at this code & output.

Code:
  if ( $sockerr ) {
    return
  }
  sockread -f %data
  echo -s (Server) ( $+ %data $+ )
  echo -s (Waiting Bytes) ( $+ $sock($sockname).rq $+ )
  echo -s ($sockbr) ( $+ $sockbr $+ ) 


Quote:
(Server) (i)
(Waiting Bytes) (410)
($sockbr) (2)


Isnt $crlf a terminator character? Such as a \r \n, etc.? Because it is doing that to a whole word. Every letter it does that to.

I tried the loop you gave, hell i was trying similar things myself. Im having no luck.

The only thing i havent tried is the binary, which i will now, though i have no idea what it does :tongue:


*edit*
Also, by looking at how many bytes i am sending in, and how many the buffer is going up by, it seems to confirm that for some reason every character being sent has an extra character tagged on it. perhaps the ASCII encoding.. i somethin. smirk

Last edited by Zeusbwr; 13/09/05 08:49 PM.
Joined: Mar 2004
Posts: 111
Z
Zeusbwr Offline OP
Vogon poet
OP Offline
Vogon poet
Z
Joined: Mar 2004
Posts: 111
got it!

Thanks for all the help! It was the encoding. Aparently when i was bashing it i left a bad encoding signature ( Unicode ) by accident.

I changed it back to ASCII and it works smile

Thanks for the help!

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yes, $crlf is a terminating character (carriage return + line feed). Without it, the line won't get read properly into a variable. -f helps with this (that's why you got results after adding it).

It would probably help if you could give a direct output of what your C# program is sending. You said it's an array. How is it sending the array? I'm thinking that perhaps your method of sending the data is where you're having problems. You might consider checking how you are sending it and seeing if you can store it as a regular variable and send that, rather than sending it as an array.


Invision Support
#Invision on irc.irchighway.net
Joined: Mar 2004
Posts: 111
Z
Zeusbwr Offline OP
Vogon poet
OP Offline
Vogon poet
Z
Joined: Mar 2004
Posts: 111
No thats the .NET Namespace.

Its functions to send any socket data is a Byte Array.

I am having issues with odd results. for example, with the -f flag,

this will be recived. ( note that there is no \n at the end of the line (behind blap)
Quote:

/command -s blap



this will not send. Erm, it will not recieve the h. Note that again, there is no \n behind h, but it will recive the h if i add a return (\n) after it.
Quote:

/command -s blap

h

Joined: Sep 2005
Posts: 1
F
Mostly harmless
Offline
Mostly harmless
F
Joined: Sep 2005
Posts: 1
well, i'm not sure if you fixed the problem already
but afaik you could just use this C# code instead:

Code:
 			byte[] byteSendData = Encoding.ASCII.GetBytes( sData.ToString() );
			this.socketClient.Send( byteSendData );  


i'm not sure if that actually helps but you can just send a string instead of a char array...


Link Copied to Clipboard