Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using winsock with out mswinsock.ocx

Posted on 1999-08-02
7
Medium Priority
?
396 Views
Last Modified: 2013-11-13
Can some one give me an example how to use wincosk with out the mswinsock.ocx.
i got the winsock.bas file but i have no idea how to use it Any help would be great. thanks
0
Comment
Question by:gholami
[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
  • 5
  • 2
7 Comments
 
LVL 6

Expert Comment

by:setiawan
ID: 1529096
0
 
LVL 6

Expert Comment

by:setiawan
ID: 1529097
I don't know what winsock.bas contained, (it supposed to be user made module). Can you post your winsock.bas ?
0
 

Author Comment

by:gholami
ID: 1529098
That is still using mswinsock.ocx
I do not want to use that file to added to my project
the winsock.bas is a bunch of api commands i can mail you the winsock.bas source if that is what you want
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 6

Accepted Solution

by:
setiawan earned 400 total points
ID: 1529099
paste into notepad save as finger.frm then add to your project
VERSION 4.00
Begin VB.Form Finger
   Caption         =   "Finger"
   ClientHeight    =   4140
   ClientLeft      =   1050
   ClientTop       =   1455
   ClientWidth     =   6690
   Height          =   4545
   Left            =   990
   LinkTopic       =   "Form1"
   ScaleHeight     =   4140
   ScaleWidth      =   6690
   Top             =   1110
   Width           =   6810
   Begin VB.CommandButton DoFinger
      Caption         =   "Send"
      Height          =   255
      Left            =   5880
      TabIndex        =   4
      Top             =   120
      Width           =   735
   End
   Begin VB.TextBox HostResponse
      BeginProperty Font
         name            =   "Courier New"
         charset         =   0
         weight          =   400
         size            =   8.25
         underline       =   0   'False
         italic          =   0   'False
         strikethrough   =   0   'False
      EndProperty
      Height          =   3615
      Left            =   120
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   3
      Top             =   480
      Width           =   6495
   End
   Begin VB.TextBox Host
      Height          =   285
      Left            =   2400
      TabIndex        =   1
      Top             =   120
      Width           =   3375
   End
   Begin VB.TextBox UserID
      Height          =   285
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   2055
   End
   Begin VB.Label Label1
      Alignment       =   2  'Center
      Caption         =   "@"
      Height          =   255
      Left            =   2160
      TabIndex        =   2
      Top             =   120
      Width           =   255
   End
End
Attribute VB_Name = "Finger"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Dim formHeightDiff As Integer
Dim formWidthDiff As Integer
Private Sub Form_Load()
    formHeightDiff = Finger.Height - HostResponse.Height
    formWidthDiff = Finger.Width - HostResponse.Width
End Sub

Private Sub Form_Resize()
    HostResponse.Height = Finger.Height - formHeightDiff
    HostResponse.Width = Finger.Width - formWidthDiff
End Sub

Private Sub DoFinger_Click()
    Dim RC As Integer
    Dim StartupData As WSADataType
    Dim Sock As Integer
    Dim SocketBuffer As sockaddr
    Dim IPAddr As Long
    Dim MsgBuffer As String * 2048
    Dim Bytes As Integer

    HostResponse.Text = ""
    RC = WSAStartup(&H101, StartupData)
    If RC = SOCKET_ERROR Then Exit Sub
    IPAddr = GetHostByNameAlias(Host)
    If IPAddr = -1 Then
        HostResponse.Text = "Unknown Host: " + Host
        Exit Sub
    End If

    Sock = socket(AF_INET, SOCK_STREAM, 0)
    If Sock = SOCKET_ERROR Then
        HostResponse.Text = "Cannot Create Socket."
        Exit Sub
    End If

    SocketBuffer.sin_family = AF_INET
    SocketBuffer.sin_port = GetServiceByName("finger", "TCP")
    SocketBuffer.sin_addr = IPAddr
    SocketBuffer.sin_zero = String$(8, 0)
    RC = connect(Sock, SocketBuffer, Len(SocketBuffer))
    If RC = SOCKET_ERROR Then
        HostResponse.Text = "Cannot Connect to Finger Server." + _
                            Chr$(13) + Chr$(10) + _
                            GetWSAErrorString(WSAGetLastError())
        closesocket Sock
        RC = WSACleanup()
        Exit Sub
    End If

    MsgBuffer = UserID + Chr$(13) + Chr$(10)
    RC = send(Sock, ByVal MsgBuffer, Len(UserID) + 2, 0)
    If RC = SOCKET_ERROR Then
        HostResponse.Text = "Cannot Send Request." + _
                            Chr$(13) + Chr$(10) + _
                            Str$(WSAGetLastError()) + _
                            GetWSAErrorString(WSAGetLastError())
        closesocket Sock
        RC = WSACleanup()
        Exit Sub
    End If

    Do
        Bytes = recv(Sock, ByVal MsgBuffer, 20, 0)
        HostResponse = HostResponse + Left$(MsgBuffer, Bytes)
    Loop While Bytes > 0
    closesocket (Sock)
    RC = WSACleanup()
End Sub

0
 
LVL 6

Expert Comment

by:setiawan
ID: 1529100
0
 
LVL 6

Expert Comment

by:setiawan
ID: 1529101
0
 

Author Comment

by:gholami
ID: 1529102
Thanks man....
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

715 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