| Mirage Source http://miragesource.net/forums/ |
|
| Sendfile Via Winsock http://miragesource.net/forums/viewtopic.php?f=201&t=3692 |
Page 1 of 1 |
| Author: | Rezeyu [ Tue May 06, 2008 2:08 am ] |
| Post subject: | Sendfile Via Winsock |
I've seen a ton of sample code, and snippets, but I'm really bad with networking (Even outside Winsock) How would I send a file as a string (binary right?) then receive it on the client's end? |
|
| Author: | Pbcrazy [ Tue May 06, 2008 2:32 am ] |
| Post subject: | Re: Sendfile Via Winsock |
now i cant get it to work all of the time but i now most of the syntax for it say you made your server stuff and made your winsock and named it SockMain then you would prolly want to prep your data if your are doing packets (like the way Mirage does) if not then you can just skip this step Code: Dim Packet as string Dim SentData as string SentData = this is where you could either say it would come directly from a text box or label or you could have it as a variable for the sub this is in Packet = "Whateveryourpacketnameshouldbe" & SEP_CHAR & SentData & SEP_CHAR & END_CHAR SockMain(Index).SendData Packet 'now im not sure exaclty about the index but i think thats how you do it now youll want to go to your client and make another winsock and well call it SockMain too this would go with the rest of the coding for the form that your winsock is on Code: Private Sub sockMain_DataArrival(ByVal bytesTotal As Long) sockMain.GetData strData, vbString Call HandleData(bytesTotal) End Sub now i usually put this in modClientTCP but you dont have to Code: Sub HandleData(ByVal Data As String) Dim Msg As String Dim Parse() As String If Parse(0) = "Whateveryourpacketnameshouldbe" Then Msg = Parse(1) Call DoWhatEverWithMsgData(Msg) End If End Sub and here are some tuts on another site that i find useful a simple client server http://www.vb6.us/tutorials/client-server-chat-program-using-winsock-control-tutorial a multiple client server http://www.vb6.us/tutorials/multiple-client-server-chat-program-using-winsock-control hope this helps |
|
| Author: | Rezeyu [ Tue May 06, 2008 2:52 am ] |
| Post subject: | Re: Sendfile Via Winsock |
Thanks, but I know how to use it for string packet data, I'm unsure of how to write the data to a file in image format. |
|
| Author: | Pbcrazy [ Tue May 06, 2008 12:19 pm ] |
| Post subject: | Re: Sendfile Via Winsock |
i dont understand XD in that case i have no clue |
|
| Author: | Lea [ Tue May 06, 2008 12:20 pm ] |
| Post subject: | Re: Sendfile Via Winsock |
Load the image into a byte array. Send it that way, then convert the area inbetween the two SEP_CHAR s into a byte array and write it to the file. |
|
| Author: | Robin [ Tue May 06, 2008 12:56 pm ] |
| Post subject: | Re: Sendfile Via Winsock |
Just use Inet. |
|
| Author: | Rezeyu [ Tue May 06, 2008 7:29 pm ] |
| Post subject: | Re: Sendfile Via Winsock |
I don't know how to use Inet for a PC, if they aren't set up as a web server. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|