Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement] More simple samples on separate Client-Server apps #7

Closed
dragokas opened this issue Sep 8, 2020 · 6 comments
Closed

Comments

@dragokas
Copy link

dragokas commented Sep 8, 2020

Suggestion:

client-server

to have more minimalistic samples. Projects attached.
Winsock-simple.zip

Also, don't you mind to clarify:

  1. do I correctly stop the connection:
Private Sub cmdStop_Click()
    Dim i&
    For i = 0 To ctxServer.UBound
        If Not (ctxServer(i) Is Nothing) Then
            ctxServer(i).Close_
        End If
    Next
  1. Comparing to Chat\Project1.vbp sample, where user control is not used, what is a difference? Is that mean, it is not multithreaded, so some side-effects are expected?

Thank you.

@wqweto
Copy link
Owner

wqweto commented Sep 8, 2020

  1. Yes, server stop looks ok. This will probably unload the control in CloseEvent too. (You can remove Close event impl as there is no Close event at all).
  2. You don't need a Winsock control per se, it's a crutch for those familiar with VB6 provided one. You can directly use cAsyncSocket (or cTlsSocket) to establish socket connections

cTlsSocket is source-compatible with cAsyncSocket meaning that if some code is using plain TCP connections with cAsyncSocket it can easily be migrated to TLS secured ones by just replacing the socket class w/ cTlsSocket.

Btw, there is a long-standing TODO to migrate chat sample to optional secure sockets w/ cTlsSocket. Unfortunately DTLS (the TLS over UDP) is not implemented yet.

@dragokas
Copy link
Author

dragokas commented Sep 8, 2020

I see, thanks.
Unfortunately, I don't familiar with old known socket control. But, I see the reason :) Сonveniently +1

However, what if the main thread busy with some time-consuming operation, let's say 1 sec (or some amount of time > timeout), and during this time net packet is incoming? Does user control version have a benefit in such case? I didn't test yet this case, though.

@wqweto
Copy link
Owner

wqweto commented Sep 10, 2020

When main UI thread is busy no socket events can be received on this main UI thread so communication is paused until main thread can pump messages (becomes available) again. There is no difference in this behavior between MS Winsock controll, cAsyncSocket class and ctxWinsock replacement control.

@dragokas
Copy link
Author

dragokas commented Sep 30, 2020

Updated GET samples.
Thanks a lot for your detailed explanation in PM.

Winsock-simple.zip

946896

Remains to do a fix for HTTPS to make it work...

@wqweto
Copy link
Owner

wqweto commented Sep 30, 2020

In ctxWinsock_DataArrival you don't need ctxWinsock.PeekData sBuffer before call to actual GetData method.

The PeekData method only peeks at recv buffer without removing the data from recv buffer. It is left in sample probably because I've been debugging it. Sorry about that!

@wqweto
Copy link
Owner

wqweto commented Oct 24, 2020

Project added under samples directory in 4dc96d3

10x!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants