dcsimg
Results 1 to 14 of 14

Thread: VB6 - Personal Chat

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    783

    VB6 - Personal Chat

    PChat is a 2 part program consisting of a server component and a client component. The client component (PChat.vbp) runs as a Desktop Application, whereas the Server component can run as a Service or a Desktop Application.

    PChat is short for Personal Chat, as it provides for a single connection between two independent parties. Each client must have a UserID, but the UserID is not password protected and the messages are not encrypted. The Client component utilizes SimpleSock acting either as a listening socket, or as a connecting socket. The Server component utilizes SimpleServer acting as a single listening socket open to as many clients as the user chooses to support. It also utilizes NTSVC.OCX to support operating as a service. The server component is open to anyone, and only serves to allow the two independent parties to connect. Each party logs into the server and stays connected. A Heart Beat signal is periodically sent to the server to maintain the connection. If the server fails to receive the Heart Beat, the user is removed from the Connect list.

    The first time the Client program is run, there are enough defaults to allow the program to start, but "Setup" from the menu needs to be run. You will be prompted to enter a UserID of 3 to 10 characters. Any UserID can be used, but if it conflicts with another user, it will have to be changed. Next, you will be asked for a "Server". The server can be a properly registered Domain Name, or an IP address. Although the program is capable of handling IPv6, it is currently only configured for IPv4. Next you will be asked for a "Server Port number". Any port number can be used, but it has to be the same as the server (default is 259). Next you will be asked for an "External Port number". This one is slightly more complex. More on that later. Next you will be asked if you want to activate Spell Check (Yes or No). Both components utilize the Microsoft InkEdit Control 1.0, which provides support for Spell Check and Unicode wide characters. That's it for the Setup.

    In order for 2 parties to connect, one of them has to have an open port listening for a connection. Most IPv4 clients are sitting behind a NAT router, and an internal Firewall. Therefore, you must configure your router to either forward the connection request on the External Port number you entered in the "Setup" process, or configure it to use Port Triggering on that Port number. Port Triggering does not require fixed IP addressing, but Port Forwarding does. Fixed IP addressing can be accomplished by configuring your network adapter, or in most modern routers, by using DHCP to provide the same function. You can still use Personal Chat without setting up your router, but you will not be able to initiate the connection. To initiate the connection, you click on the "Get Connected Users" button. This will recover the currently connected users from the server.

    Note: The address to connect to is supplied by the server. That is how the External IP address is recovered. As long as the server is operating on a network separate from either client, that address will be the Public IP address of the client. If a client is operating on the same network as the server, the server will only see the Private IP address. If both clients are on the same network as the server, those 2 clients will be able to connect to each other, but neither will be able to connect to an outside client. However, if you choose to provide the server setup with an External IP address, and the requesting client is on the same network as the server, the External IP address will be supplied to the requested client. Under this scenario, you can still use the program on the local network by changing the public address to the private address before connecting.

    Clicking on one of the User Names will send that User Name, your External IP Address, and your External Port number to the server, and open the chat socket in the listening mode. The server will then forward that Address and Port information to the selected user. The selected user will receive this information and display it in several boxes. If PChat is minimized when the request is received, it will be restored to a normal window. Clicking on the green User Name box will attempt to establish a connection with the user at the Address and Port displayed. The Client receiving the connection request is given 5 minutes to respond to the request. At the end of that period, the request is withdrawn and the listening socket closed.

    Note: The party listening for the connection must allow that connection through the Firewall. If the Microsoft Firewall is being used, on the first connection attempt you will be asked if you want to allow that connection. Responding to that question may cause the first attempt to time out.

    The two sides can then carry on a conversation.

    The server component (PChatS.vbp) runs as a Service, and must be accessible from the WAN (Wide Area Network, aka Internet) on a listening port of your choosing (default 259). The service has no visible components and operates with system privileges in Session 0. It comes with a small management program (prjInterface.vbp) to provide the necessary interface between the Service Manager (services.msc) and the service itself. The server component will compile as a Desktop Application as supplied. To compile as a Service, change "frmHidden.Visible" to "False", and the "IsService" flag to "True". I used "PChatS.exe" for the Desktop version, and "PChatSvc.exe" for the Service version. The server component requires "NTSVC.OCX" and a location for the log files. The "Desktop" uses a sub directory of the application directory called "Logs", and the Service uses "\Windows\System32\Logfiles\PChat\".
    Attached Images Attached Images    
    Attached Files Attached Files
    Last edited by couttsj; Mar 27th, 2018 at 04:32 PM.

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    783

    Re: VB6 - Personal Chat

    Version 2 of PChat adds optional encryption on the link between the two connected parties. That choice is made from the end making the connection request, simply by clicking on the "Encrypt" option button. Otherwise it operates the same as Version 1.

    Any good security system also requires some form of authentication. But because this system is direct (one to one) and non-automated, the authentication can be as good as you want to make it. Because the connection is already encrypted, you can exchange information only you and the recipient are aware of, in any format you agree on. This could be similar to the verification information some sites require, like "What is your mother's maiden name?". The keys are 256 bit ECC (Elliptical Curve Cryptography) keys, and utilize my jcrypt.dll Encryption library. The keys are different for every session, and are generated by combining the Public Key from the other end with the Private key from your end. No keys are stored.

    There are no changes required to the server program.

    J.A. Coutts
    Attached Files Attached Files
    Last edited by couttsj; Mar 27th, 2018 at 04:33 PM.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    783

    Re: VB6 - Personal Chat

    Beta testing revealed that some users had trouble with connecting and with using the same message box for input. Therefore, a secondary box was added for input only. The "Get Connected Button" was removed and that function added to the menu. An illegal character was added to the other users name so that Spell Check would underline it, but that did not work in Win 10. So a formatting routine was added to color one user's input blue.

    J.A. Coutts

  4. #4
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    371

    Re: VB6 - Personal Chat

    Quote Originally Posted by couttsj View Post
    PChat is a 2 part program consisting of a server component and a client component. The client component (PChat.vbp) runs as a Desktop Application, whereas the Server component can run as a Service or a Desktop Application.

    PChat is short for Personal Chat, as it provides for a single connection between two independent parties. Each client must have a UserID, but the UserID is not password protected and the messages are not encrypted. The Client component utilizes SimpleSock acting either as a listening socket, or as a connecting socket. The Server component utilizes SimpleServer acting as a single listening socket open to as many clients as the user chooses to support. It also utilizes NTSVC.OCX to support operating as a service. The server component is open to anyone, and only serves to allow the two independent parties to connect. Each party logs into the server and stays connected. A Heart Beat signal is periodically sent to the server to maintain the connection. If the server fails to receive the Heart Beat, the user is removed from the Connect list.

    The first time the Client program is run, there are enough defaults to allow the program to start, but "Setup" from the menu needs to be run. You will be prompted to enter a UserID of 3 to 10 characters. Any UserID can be used, but if it conflicts with another user, it will have to be changed. Next, you will be asked for a "Server". The server can be a properly registered Domain Name, or an IP address. Although the program is capable of handling IPv6, it is currently only configured for IPv4. Next you will be asked for a "Server Port number". Any port number can be used, but it has to be the same as the server (default is 259). Next you will be asked for an "External Port number". This one is slightly more complex. More on that later. Next you will be asked if you want to activate Spell Check (Yes or No). Both components utilize the Microsoft InkEdit Control 1.0, which provides support for Spell Check and Unicode wide characters. That's it for the Setup.

    In order for 2 parties to connect, one of them has to have an open port listening for a connection. Most IPv4 clients are sitting behind a NAT router, and an internal Firewall. Therefore, you must configure your router to either forward the connection request on the External Port number you entered in the "Setup" process, or configure it to use Port Triggering on that Port number. Port Triggering does not require fixed IP addressing, but Port Forwarding does. Fixed IP addressing can be accomplished by configuring your network adapter, or in most modern routers, by using DHCP to provide the same function. You can still use Personal Chat without setting up your router, but you will not be able to initiate the connection. To initiate the connection, you click on the "Get Connected Users" button. This will recover the currently connected users from the server.

    Note: The address to connect to is supplied by the server. That is how the External IP address is recovered. As long as the server is operating on a network separate from either client, that address will be the Public IP address of the client. If a client is operating on the same network as the server, the server will only see the Private IP address. If both clients are on the same network as the server, those 2 clients will be able to connect to each other, but neither will be able to connect to an outside client. However, if you choose to provide the server setup with an External IP address, and the requesting client is on the same network as the server, the External IP address will be supplied to the requested client. Under this scenario, you can still use the program on the local network by changing the public address to the private address before connecting.

    Clicking on one of the User Names will send that User Name, your External IP Address, and your External Port number to the server, and open the chat socket in the listening mode. The server will then forward that Address and Port information to the selected user. The selected user will receive this information and display it in several boxes. If PChat is minimized when the request is received, it will be restored to a normal window. Clicking on the green User Name box will attempt to establish a connection with the user at the Address and Port displayed. The Client receiving the connection request is given 5 minutes to respond to the request. At the end of that period, the request is withdrawn and the listening socket closed.

    Note: The party listening for the connection must allow that connection through the Firewall. If the Microsoft Firewall is being used, on the first connection attempt you will be asked if you want to allow that connection. Responding to that question may cause the first attempt to time out.

    The two sides can then carry on a conversation.

    The server component (PChatS.vbp) runs as a Service, and must be accessible from the WAN (Wide Area Network, aka Internet) on a listening port of your choosing (default 259). The service has no visible components and operates with system privileges in Session 0. It comes with a small management program (prjInterface.vbp) to provide the necessary interface between the Service Manager (services.msc) and the service itself. The server component will compile as a Desktop Application as supplied. To compile as a Service, change "frmHidden.Visible" to "False", and the "IsService" flag to "True". I used "PChatS.exe" for the Desktop version, and "PChatSvc.exe" for the Service version. The server component requires "NTSVC.OCX" and a location for the log files. The "Desktop" uses a sub directory of the application directory called "Logs", and the Service uses "\Windows\System32\Logfiles\PChat\".
    I am very interested in your setup program as a service, but I think your program is very confusing. I am very confused. For example, the prjInterface.vbp code is a registered system service, NTSVC.ocx is a registered system service... and I use After NTSVC.ocx and prjInterface.vbp register the service, it is found that the service startup is unstable in my win7 system . Thank you for the code

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    783

    Re: VB6 - Personal Chat

    Quote Originally Posted by xxdoc123 View Post
    I am very interested in your setup program as a service, but I think your program is very confusing. I am very confused. For example, the prjInterface.vbp code is a registered system service, NTSVC.ocx is a registered system service... and I use After NTSVC.ocx and prjInterface.vbp register the service, it is found that the service startup is unstable in my win7 system . Thank you for the code
    If you have never made a service before, I can understand that you might find it confusing. A service is a System file that operates in Session 0 like all system files. As such, it must not attempt to interface with the Desktop, which operates in Session 1+. For example, it must not use things like a MsgBox. Doing so can cause the operating system to go into an endless loop when you are not logged in. Use a log file for all user notification.

    A service usually runs under the control of the Service Manager (services.msc). To accommodate that requires the use of an ActiveX library such as NTSVC.ocx. NTSCV provides the interface between the service and the Service Manager. It is not an actual service.

    PChatCtrl (compiled from prjInterface.vbp) is also not a service, nor is it registered in the system. "Service1" (from NTSCV) does contain the code necessary to register a program as a service in the subroutine "ChkInstall", but since there are other setup requirements to operate this particular service, "prjInterface" was developed. Once the service is installed and properly setup, all functions can be controlled directly from the Service Manager.

    "prjPChatS.vbp" is unique in that it can also be run as a Desktop application. That is how it will run as supplied in the download and compiled as "PChatS.exe". To compile it as a Service, change the "IsService" flag to True, and change "frmHidden.Visible" to False. Then compile it as "PChatSvc.exe". You would normally only do this after you have worked out the kinks on the Desktop version. Once you have created the service program, "PChatCtrl" can be used to install it as a service and run setup. Because "PChatCtrl" is accessing restricted areas of the registry and file system, it must be run in "Administrative" mode. "PChatSvc" has been running on my Win 8.1 system for the past several months without a hitch.

    J.A. Coutts

  6. #6
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    371

    Re: VB6 - Personal Chat

    Quote Originally Posted by couttsj View Post
    If you have never made a service before, I can understand that you might find it confusing. A service is a System file that operates in Session 0 like all system files. As such, it must not attempt to interface with the Desktop, which operates in Session 1+. For example, it must not use things like a MsgBox. Doing so can cause the operating system to go into an endless loop when you are not logged in. Use a log file for all user notification.

    A service usually runs under the control of the Service Manager (services.msc). To accommodate that requires the use of an ActiveX library such as NTSVC.ocx. NTSCV provides the interface between the service and the Service Manager. It is not an actual service.

    PChatCtrl (compiled from prjInterface.vbp) is also not a service, nor is it registered in the system. "Service1" (from NTSCV) does contain the code necessary to register a program as a service in the subroutine "ChkInstall", but since there are other setup requirements to operate this particular service, "prjInterface" was developed. Once the service is installed and properly setup, all functions can be controlled directly from the Service Manager.

    "prjPChatS.vbp" is unique in that it can also be run as a Desktop application. That is how it will run as supplied in the download and compiled as "PChatS.exe". To compile it as a Service, change the "IsService" flag to True, and change "frmHidden.Visible" to False. Then compile it as "PChatSvc.exe". You would normally only do this after you have worked out the kinks on the Desktop version. Once you have created the service program, "PChatCtrl" can be used to install it as a service and run setup. Because "PChatCtrl" is accessing restricted areas of the registry and file system, it must be run in "Administrative" mode. "PChatSvc" has been running on my Win 8.1 system for the past several months without a hitch.

    J.A. Coutts
    yes i konw

    Name:  error.png
Views: 232
Size:  10.5 KB

    but if i start service have error number 2

    Name:  why.PNG
Views: 232
Size:  12.2 KB



    Why this example will appear to not start the service, I believe that the installation has been successful.


    I find your other links [VB6 - EChat] url

    i tested this code [ EChatSvc] have no error.

    Name:  ok.png
Views: 234
Size:  89.7 KB
    Last edited by xxdoc123; May 14th, 2018 at 12:56 AM.

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    783

    Re: VB6 - Personal Chat

    Does the service start using the Service Manager? It is entirely possible that there is a bug in prjInterface, as I seldom if ever use it to stop & start the service. The Service Manager is also capable of changing the Startup mode to Auto and modifying the Recovery options.

    J.A. Coutts

  8. #8
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    371

    Re: VB6 - Personal Chat

    Quote Originally Posted by couttsj View Post
    Does the service start using the Service Manager? It is entirely possible that there is a bug in prjInterface, as I seldom if ever use it to stop & start the service. The Service Manager is also capable of changing the Startup mode to Auto and modifying the Recovery options.

    J.A. Coutts
    Service Manager can not start the service too!?

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    783

    Re: VB6 - Personal Chat

    Quote Originally Posted by xxdoc123 View Post
    Service Manager can not start the service too!?
    In the Service Manager, Check the path to the executable. You can actually run the executable from the Desktop, but of course there is no viewable window, and the only way of stopping the program is via the Task Manager. The path should be one that is accessible to the system. On my machine, it is located at:
    C:\Program Files (x86)\pChat\PChatSvc.exe

    It also will not run if it is not properly setup. The setup must be run after the service is installed, and before starting it. If you uninstall the service and re-install it, the operating system will have removed the registry entries. Check the registry entries at:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\PChatSvc\Parameters
    There you should find ExternalIP, IPVersion, MaxSockets, & Port Listen. If they exist, then check that the listening socket is not already in use using the command "netstat -an".

    J.A. Coutts

  10. #10
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    371

    Re: VB6 - Personal Chat

    i find echat code work well.this pcode not. i can not find why .so.

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    783

    Re: VB6 - Personal Chat

    Quote Originally Posted by xxdoc123 View Post
    i find echat code work well.this pcode not. i can not find why .so.
    I sent you a PM requesting the executable.

    J.A. Coutts

  12. #12
    Hyperactive Member
    Join Date
    Aug 2016
    Posts
    371

    Re: VB6 - Personal Chat

    thanks .now i test ok in my another PC.may can replace NTSVC.ocx with api?

  13. #13
    Frenzied Member
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    1,388

    Re: VB6 - Personal Chat

    You can write services in VB6 using Sergey Merzlikin's TLB and example code here: http://www.smsoft.ru/en/ntservice.htm. Download link is at the bottom of the page.

  14. #14

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2012
    Posts
    783

    Re: VB6 - Personal Chat

    Quote Originally Posted by xxdoc123 View Post
    thanks .now i test ok in my another PC.may can replace NTSVC.ocx with api?
    Something you may try is the Event logs. Service Manager events are supposed to be logged, and that should include all errors. For example:
    Code:
    Service1.LogEvent svcMessageError, svcEventError, "[" & Err.Number & "] " & Err.Description
    For reasons unknown (to me), I can't seem to find these events on Win 8.1 (and probably Win 10), but Win 7 is very similar to Vista, which logged them properly.

    J.A. Coutts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width