[NetBIOS] Can't send msg to registered name
- From: Gilles Ganault <nospam@xxxxxxxxxx>
- Date: Mon, 20 Aug 2007 19:42:57 +0200
Hello
I'd like to have a server register a new NetBIOS name on a LAN
so that clients can locate it by broadcasting a query (this LAN has no
DNS, and no WINS). Once it is located, clients will connect to its
named pipe to tx/rx data.
Using the following VB Classic code, I can successfully register a new
name, but "net send" doesn't work:
==========
Const NCBNAMSZ = 16
Private Type NCB
ncb_command As Byte
ncb_retcode As Byte
ncb_lsn As Byte
ncb_num As Byte
ncb_buffer As Long
ncb_length As Integer
ncb_callname As String * NCBNAMSZ
ncb_name As String * NCBNAMSZ
ncb_rto As Byte
ncb_sto As Byte
ncb_post As Long
ncb_lana_num As Byte
ncb_cmd_cplt As Byte
ncb_reserve(9) As Byte
ncb_event As Long
End Type
Private Const NCBADDNAME = &H30 ' NCB ADD NAME
Private Const NCBRESET = &H32
Private Const NRC_GOODRET = &H0 ' good return
Private Const NCBSEND = &H14 ' NCB SEND
'! Name MUST be 15 characters long: if shorter, add spaces
Private Const SERVER_NAME = "MY_GREAT_SERVER"
Private Declare Function Netbios Lib "netapi32.dll" (pncb As NCB) As
Byte
Private Sub Command1_Click()
Dim ncbInfo As NCB
Dim sMachine As String * NCBNAMSZ
'Dim sMachine As String
Dim lResult As Long
Dim bRet As Byte
'sMachine = Space$(16)
'===========1. Send RESET
With ncbInfo
.ncb_command = NCBRESET
End With
bRet = Netbios(ncbInfo)
MsgBox bRet
'===========2. Register name
sMachine = SERVER_NAME & Chr(3)
With ncbInfo
.ncb_command = NCBADDNAME
.ncb_name = sMachine
.ncb_lana_num = 0
End With
bRet = Netbios(ncbInfo)
MsgBox bRet
'Can't use net send
'C:\>nbtstat -n
'
' JOE <03> UNIQUE Registered
' MY_GREAT_SERVER<03> UNIQUE Registered
'
'C:\>net name
'Name
'-----------------------------------------------------------------
'MYPUTER
JOE
'The command completed successfully.
'
'C:\>net send joe test
'The message was successfully sent to JOE.
'
'C:\>net send my_great_server test
'An error occurred while sending a message to MY_GREAT_SERVER.
'
'The message alias could not be found on the network.
'===========3. Have client hosts send broadcast to locate
'===========4. Clients connect to \\MY_GREAT_SERVER\pipes\mypipe"
to tx/rx data
End Sub
==========
Is there a step missing?
Thank you.
.
- Prev by Date: Re: UDP exeption 10040"message too long"
- Next by Date: Re: Device not responding? Remote reboot?
- Previous by thread: Query Remote MAC addresses
- Next by thread: why inet_ntoa() may return 0? Under what condition?
- Index(es):
Relevant Pages
|
|