Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Simply question

Posted on 2003-12-02
7
Medium Priority
?
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 1000 total points
ID: 9902399
Thanks, If you have any questions IM me
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

597 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