Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
Beginner
Date of registration: Mar 16th 2009
Location: Caracas, Venezuela - Bogota, Colombia
Occupation: Senior Developer - SLM Sistemas
Hobbies: Developing, Securiy, others
Here is some of the code me and Goldenshox used on our project.Hello, i want to develop a Socket Server using JABACO ... in VB6 i use a socket array ... the socket(0) is the listener socket, and i create at runtime other sockets that accept the requestid ... here in JABACO i can't see the control arrays .. so i think the concept is something different ... can anyone help me with an example?
Thanks a lot.
Source code |
|
1 2 3 4 |
Dim SocketInteger As Integer, SocketList As String SocketInteger = SocketInteger + 1 SocketList = SocketList & SocketInteger & ";" |
Beginner
Date of registration: Mar 16th 2009
Location: Caracas, Venezuela - Bogota, Colombia
Occupation: Senior Developer - SLM Sistemas
Hobbies: Developing, Securiy, others
Really Thanks for your help .. but i still don't understand ...Here is some of the code me and Goldenshox used on our project.Hello, i want to develop a Socket Server using JABACO ... in VB6 i use a socket array ... the socket(0) is the listener socket, and i create at runtime other sockets that accept the requestid ... here in JABACO i can't see the control arrays .. so i think the concept is something different ... can anyone help me with an example?
Thanks a lot.
Source code
1 2 3 4 Dim SocketInteger As Integer, SocketList As String SocketInteger = SocketInteger + 1 SocketList = SocketList & SocketInteger & ";"
We placed that in ConnectionRequest theres a bit more to it but its specific to our server I hope you can work off from this
Beginner
Date of registration: Mar 16th 2009
Location: Caracas, Venezuela - Bogota, Colombia
Occupation: Senior Developer - SLM Sistemas
Hobbies: Developing, Securiy, others
Source code |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
Public Sockets() As winsock Public Sub Form_Load() sock.Listen ' This is the Listening Socket, never touch this state ;) End Sub Public Sub sock_ConnectionRequest(requestSocket As Socket) Dim Index As Long Index = Ubound(sockets)+1 'Create new Index from the last in the array + 1 Redim sockets(Index) 'Redim the array Set sockets(index) = New Winsock 'Load a new instance of the Winsock Control in the container sockets(index).Accept requestsocket 'This new instance accept the requestsocket End Sub Public Sub sockets_DataArrival(bytesTotal As Long) 'here i dont receive nothing End Sub Public Sub sockets()_DataArrival(bytesTotal As Long) 'This make an error because the "()" End Sub Public Sub sockets_DataArrival(bytesTotal As Long, Index as long ) 'This is a madness :evil: End Sub |
Beginner
Date of registration: Mar 16th 2009
Location: Caracas, Venezuela - Bogota, Colombia
Occupation: Senior Developer - SLM Sistemas
Hobbies: Developing, Securiy, others
Source code |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
Public Sockets() As winsock Private Sub Form_Load() sock.Listen 'Let's open the port :) End Sub Private Sub sock_ConnectionRequest(requestSocket As Socket) Dim NewSocket As Winsock Set NewSocket = GetEmptySocket() 'Use the magic function :P NewSocket.Accept requestsocket 'Acept the input client End Sub Private Function GetEmptySocket() As Winsock Dim Index As Long index = -1 For i = 0 To Ubound(Sockets) 'Lets see if there is a empty slot in the array If Sockets(i) = Nothing Then 'We found an Empty Slot index = i Exit For 'Exit the loop End If Next i If index = -1 Then 'We dont found a empty slot, so we grow the array (create a slot) Index = Ubound(Sockets)+1 Redim Preserve Sockets(Index) End If Set Sockets(index) = New Winsock Set GetEmptySocket = sockets(index) 'Load and put the new socket '################################################################ 'TODO: Search for Empty Bounds to decrease the size of the array '################################################################ End Function Private Sub Timer1_Timer() 'This timer will handle the arrive of data for all the sockets and Generate And Event to handle Dim sData As String For i = 0 To Ubound(sockets) 'Let's search in all the sockets If sockets(i) <> Nothing Then 'If this is a empty Slot then exit If sockets(i).State <> 7 Then 'If this Socket is recently closed :::TODO::: Generate Event Disconected Set sockets(i) = Nothing 'Lets remove the instance ... getting an empty slot :) Else sData = sockets(i).GetData 'Lets get the input buffer If sData <> "" Then 'If there is something in the buffer msgbox "Data received from socket: " & i & " the data: " & sData 'MessageBox the Socket Number and the received data End If End If End If Next i End Sub |
Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
Beginner
Date of registration: Mar 16th 2009
Location: Caracas, Venezuela - Bogota, Colombia
Occupation: Senior Developer - SLM Sistemas
Hobbies: Developing, Securiy, others
i can't be more agree with you ... as you maybe know, this one is my first software in JABACO ... ... now, i have a second one .. i will upload later .. is a way to print to LPT (LPT1 in Windows, /dev/lp0 in Linux (*x) ... i don't know much about super classes and herency because i'm a old vb6 developer ... but, i know the concept of course ... so .. i will read your post (really thanks) and will make my best to do the superclass (not a hero one lolHi,
great! You have implemented a kind of socket pooling with a dynamically growing array of Winsocks.
The drawback is that you need a timer to scan your Winsocks periodically.
My suggestion would be to invent a class "clsMyWinsock" with super class Winsock (Property SuperClass=VB/Winsock).
This class could then overload event handling routines of Winsock.
Whenever something happens to your Winsock, the event handler would take care for it.
I posted a similar solution for Controls in January.
What do you think?
A1880