Solved

Simply question

Posted on 2003-12-02
7
229 Views
Last Modified: 2013-11-20
Okay i have a program that I wrote in visual basic which I have had trouble converting it into MFC can someone help me out on how i can convert the code to MFC?

This code as you can see connects to port 4443, listens for data, puts the received data on a list box and if the Option1 radio button is clicked it closes the port for listening.

Visual Basic Code:

Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
List1.AddItem "Time: " & Time & " - " & Winsock1.RemoteHostIP & " - Direct Connect"
Winsock1.Close
Winsock1.LocalPort = 4443
Winsock1.Listen
End Sub
--------------------------
Private Sub Option1_Click()
If Option1.Value = True Then Winsock1.Close
End Sub
0
Comment
Question by:sdgaf
7 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 9864112
you can use the WinSoct Control in VC using the "Project->Add To Project->Components and Controls" menu.
This will givee you a wrapper class of winsock, call the same functions with brackets....becoz vc uses set/get functions instead of properties.

Rosh :)
0
 

Author Comment

by:sdgaf
ID: 9868655
I used the following code and got errors saying Winsock1 undeclared. and LocalPort, Listen, and Close must point to a struct/class

Winsock1.LocalPort( 4443 );
Winsock1.Listen();
..
..
Winsock1.Close();
0
 

Expert Comment

by:Drew_Benton
ID: 9892065
Ok as in roshmon's post, add that component. But there is more stuff you need to do to use this control. Open up your main Dialog, drag the new component (Miscrosoft WinSock Control 6.0 ) onto the dialog. Now hold down "ctrl" and double click on the winsock control. A new dialog should pop up, "Add Member Variable" for the name make it "Winsock1". Now hit ok. Now your code will work. ( I hope =) )
- Drew
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Expert Comment

by:Drew_Benton
ID: 9892067
Clarification: "double click on the winsock control" thats on your dialog.
0
 

Author Comment

by:sdgaf
ID: 9893723
I do not see the winsock control in 6.0. I see every other control except for winsock. How do i get the winsock????
0
 

Expert Comment

by:Drew_Benton
ID: 9893854
ok do this:
Project ( at the top of the VC++ Window)->Add To Project (second item in the menu)->Components and Controls (the last item in that menu)
A new window will pop up, double click on the "Registered ActiveX Controls" folder to open it, then look for "Microsoft WinSock Control, version 6.0" (listed by alpha) so scroll midway into the 'M's'. When you find it double click on it. A confirmation will appear, hit Ok. A new dialog will popup, hit ok again, then close the "Components and Controls Gallery" window. Now try to do as I mentioned above. If you have any more ques feel free to ask.
0
 

Accepted Solution

by:
khaotiksociety earned 250 total points
ID: 9902399
Thanks, If you have any questions IM me
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now