chiSock FB socket library for Win/Lin

User projects written in or related to FreeBASIC.
cha0s
Site Admin
Posts: 5317
Joined: May 27, 2005 6:42
Location: Illinois
Contact:

chiSock FB socket library for Win/Lin

Postby cha0s » Jun 02, 2007 17:06

Download Source: http://therealcha0s.net/project/chisock%2008-24-08.zip

Compiling and API info in the README.txt.
Last edited by cha0s on Aug 24, 2008 7:41, edited 4 times in total.
zerospeed
Posts: 227
Joined: Nov 04, 2005 15:29

Postby zerospeed » Jun 03, 2007 16:51

cha0s, good implementation!

Have you thought about event-driven sockets? (callback based). I have a draft laying around, but never finished (ala get it fully working, neither cross-platform) :-P

Later.
cha0s
Site Admin
Posts: 5317
Joined: May 27, 2005 6:42
Location: Illinois
Contact:

Postby cha0s » Jun 03, 2007 18:05

Thank you. It's possible but I prefer this interface ;)

socket-???-thread.bas would be easy to have as a launch point for callbacks.
{Nathan}
Posts: 301
Joined: Jun 04, 2005 15:18
Location: Ohio
Contact:

Postby {Nathan} » Jun 04, 2007 1:05

I downloaded the archive 3 times and tried to untar it, but all times it was unsuccesful and did not extract. Can you try reupping and rearchiving please?
D.J.Peters
Posts: 7191
Joined: May 28, 2005 3:28

Postby D.J.Peters » Jun 04, 2007 1:19

link removed
Last edited by D.J.Peters on Jun 04, 2007 20:26, edited 1 time in total.
{Nathan}
Posts: 301
Joined: Jun 04, 2005 15:18
Location: Ohio
Contact:

Postby {Nathan} » Jun 04, 2007 20:25

Got it DJ -- thanks. You can remove it now.
rmann05
Posts: 50
Joined: May 31, 2005 16:02
Location: Florida
Contact:

Postby rmann05 » Jun 05, 2007 3:11

{Nathan} wrote:I downloaded the archive 3 times and tried to untar it, but all times it was unsuccesful and did not extract. Can you try reupping and rearchiving please?

Try renaming the file to chisock-6-2-07.tar.zip instead of chisock-6-2-07.zip.tar. After I did that, I could unzip the file on my Linux server.
cha0s
Site Admin
Posts: 5317
Joined: May 27, 2005 6:42
Location: Illinois
Contact:

Postby cha0s » Jun 05, 2007 6:57

Yeah, it's a zip file not a .tar.gz...
attacke
Posts: 55
Joined: Mar 19, 2006 11:57
Contact:

Postby attacke » Jul 08, 2007 19:14

umh, iv tried to make this simple irc connection with this socket library...

after some whiles i notice that something takes $%#@ of memory...
while running my pagefile are at 1.5gig.
as soon as i close the program it goes down to 200mb

heres the code.

Code: Select all

#include "socket.bi"
Const crlf = Chr(13)+Chr(10)

Dim As chi.socket so
Dim As String st

If ( so.client("se.quakenet.org",6667) <> chi.SOCKET_OK ) Then
   Print "socket Error!"
EndIf

so.put("NICK Blarfen"+crlf)
so.put("USER blarfen """" ""se.quakenet.org"" :Blarfen rockar fett"+crlf)

Do
   if( so.get( st, , , TRUE ) ) then
      so.dump_data( len(st) )
      Print st;
   end If
   st = ""
   Sleep 100
Loop Until MultiKey(&h01)

so.close()


the funnt part are that i aint getting any data back. but i see it in my firewall that there are like 400bytes both incomming and outgoing.
cha0s
Site Admin
Posts: 5317
Joined: May 27, 2005 6:42
Location: Illinois
Contact:

Postby cha0s » Jul 08, 2007 22:31

Yeah, I have to adjust the buffer allocation, i made it way too high when i was experimenting. I'll work on it eventually, but probably not today...
cha0s
Site Admin
Posts: 5317
Joined: May 27, 2005 6:42
Location: Illinois
Contact:

Postby cha0s » Jul 11, 2007 14:04

I see now what you're doing, you're reading strings, but the way my library works, is that if you send a string, first you send one integer that says how long the string is, and then the string data. So the same happens when reading. You're reading a random integer (maybe like 1721827398 :P), and then allocating a string to that length, which is wrong.

TODO: add a 'get_all' function which retrieves everything in the buffer into a string. And a 'put_all' too, for completion
Pritchard
Posts: 5425
Joined: Sep 12, 2005 20:06
Location: Ohio, USA

Postby Pritchard » Jul 11, 2007 14:20

Thanks, cha0s! This clears some things up for me :D
attacke
Posts: 55
Joined: Mar 19, 2006 11:57
Contact:

Postby attacke » Jul 23, 2007 20:19

oh... well ill give it another go.
Oz
Posts: 585
Joined: Jul 02, 2005 14:21
Location: Waterloo, Ontario, Canada
Contact:

Postby Oz » Sep 15, 2007 22:34

Hey, cha0s

I'm using the latest version of your library in an attempt to remake OzBOT, but I can't get data. You had mentioned something a few posts above, but from my understanding, it's a problem with chi-sockets....

here is how i'm trying to get a line from the irc server:

Code: Select all

function irc_sock.getLine( byref returnStr as string ) as integer

   dim getBuffer(0 to 1) as ubyte

   while this.socketInside.get_data( @getBuffer(0), 1, FALSE ) = TRUE
      if right( returnStr, 2 ) <> chr( 10, 13 ) then
         ? chr( getBuffer(0) );
         returnStr &= chr( getBuffer )
      else
         ?
         
         return TRUE
      end if
      getBuffer(0) = 0
      getBuffer(1) = 0
   wend

   return FALSE

end function


this method does not work, sadly.

any suggestions?

Oz~
cha0s
Site Admin
Posts: 5317
Joined: May 27, 2005 6:42
Location: Illinois
Contact:

Postby cha0s » Sep 16, 2007 2:18

Should be chr( getbuffer(0) ), also, it's chr(13, 10).

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 1 guest