Solved

Simple Winsock question

Posted on 2003-10-22
3
202 Views
Last Modified: 2013-11-13
I need to remotely press a key on several machines on a Win 98 network. I know I need two apps, one on the "main" machine that sends a signal out via Winsock, and one on the remote machine that looks for that signal, and presses a key once received. I'm a novice, but I know how to press the key, and I know Winsock is capable of the communication but I know nothing about winsock or how to use it.

Can anyone give me sample code, or tell me where to find it for each end that will accomplish this task?

Thanks much,
Larry L
0
Comment
Question by:larrylands
[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
3 Comments
 
LVL 1

Expert Comment

by:lamdor
ID: 9603437
Hi larry,

 I think you need to have a server application that listens to a port and u also need a client application to send a key(I donno what is signal ...u mean what kind?) ..

 There are two ways u can use a winsock control. Winsock u can use to listen to perticular port like this.. "Winsock1.Listen" and from the client u can connect to that perticualr port for which the server is binding "winsock1.connect IP,Port". I hope this helps.

 And ask me if u still have some trouble in achieving this..
 all the best.
regards
lam
0
 
LVL 6

Expert Comment

by:prasitlee
ID: 9603706
Dear larrylands,
    Let 's try the following link.
    http://www.15seconds.com/issue/010820.htm
    I am strongly sure that this link would give you a good example.
                                                        Meng
0
 
LVL 1

Accepted Solution

by:
NeXus earned 125 total points
ID: 9605228
Hi,

heres a solution for you (really simplified)...

Make 1 module & 2 forms (once you are happy copy the forms into seperate projects)

on form 1 draw 2 winsock controls (leave the names intact)
in form 1 paste :
'==============================================================

Private Sub Form_Load()
    Winsock1.LocalPort = 9000
    Winsock1.Listen
    MsgBox "Listening on port:" & 9000
End Sub


Private Sub Winsock1_ConnectionRequest(ByVal requestID As Long)
    Winsock2.Accept requestID
End Sub

Private Sub Winsock2_DataArrival(ByVal bytesTotal As Long)
    Dim data As String
    Winsock2.GetData data, vbString
    MsgBox "Received:" & data
End Sub

on form 2 draw 1 winsock control (leave the name intact)
in form 2 paste :
'==============================================================

Private m_connected As Boolean

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
    If m_connected Then
        Winsock1.SendData Chr(KeyCode)
    End If
End Sub

Private Sub Form_Load()
    Winsock1.RemoteHost = "127.0.0.1"
    Winsock1.RemotePort = 9000
    Winsock1.Connect
End Sub


Private Sub Winsock1_Connect()
    m_connected = True
    MsgBox "Connected to " & Winsock1.RemoteHostIP
End Sub

in the module  paste :
'==============================================================

Sub main()
    Form1.Show
    Form2.Show
End Sub


'==============================================================
Make sure the project is set to start with sub main
and hit F5

give focus to Form2 and type a key....

have fun!!!
NeXus



0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 241
How to make an ADE file by code? 11 100
Publisher:   Unknown     VB.exe Application 1 31
VBA: Insert New column with specific format type 12 55
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

730 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