Answered by:
Socket Programming in VB.NET

Question
-
Hey friends,
am interested in learning VB.NET socket programming.
here goes the first question in the series.
Question : How to get IP Address of current system ?Saturday, September 8, 2007 5:10 PM
Answers
-
in socket programming one might need to get ones own IP address.
for that use Sockets namespace .
The function : GetHostEntry will help u out.Saturday, September 8, 2007 5:12 PM -
That was a nice reply ma'am.
But can you give me a sample code for the same ?Saturday, September 8, 2007 5:17 PM -
here u go sanket :
Imports System.Net.Sockets
Private ips As Net.IPHostEntry = _
Net.Dns.GetHostEntry(Net.Dns.GetHostName())
this should doSaturday, September 8, 2007 5:28 PM -
Thanks swati.
Please tell me how to send fine across network.Saturday, September 8, 2007 5:41 PM -
if i am not mistaken then sanket u want to know how to send files across network.
for that sanket you need 2 main things
1) an instance of a file stream to send files across
2) an array of bytes because u need to store all the data u want to sed in the form of bytes.Saturday, September 8, 2007 5:47 PM -
its nice that you are giving concepts here. But if possible, give me a sample code.Saturday, September 8, 2007 5:50 PM
-
well luckily i do have a sample code for u sanket:
Dim fs As FileStream
Dim fileContents As Byte()
fs = New FileStream(OpenFileDialog.FileName,
FileMode.Open, FileAccess.Read, FileShare.Read, _
4096, True)
ReDim fileContents(fs.Length)
fs.BeginRead(fileContents, 0, fs.Length, callback, Nothing)Saturday, September 8, 2007 6:07 PM -
Hey its nice response.
But what "4096" is doing here ?Saturday, September 8, 2007 6:09 PM
All replies
-
in socket programming one might need to get ones own IP address.
for that use Sockets namespace .
The function : GetHostEntry will help u out.Saturday, September 8, 2007 5:12 PM -
That was a nice reply ma'am.
But can you give me a sample code for the same ?Saturday, September 8, 2007 5:17 PM -
here u go sanket :
Imports System.Net.Sockets
Private ips As Net.IPHostEntry = _
Net.Dns.GetHostEntry(Net.Dns.GetHostName())
this should doSaturday, September 8, 2007 5:28 PM -
Thanks swati.
Please tell me how to send fine across network.Saturday, September 8, 2007 5:41 PM -
if i am not mistaken then sanket u want to know how to send files across network.
for that sanket you need 2 main things
1) an instance of a file stream to send files across
2) an array of bytes because u need to store all the data u want to sed in the form of bytes.Saturday, September 8, 2007 5:47 PM -
its nice that you are giving concepts here. But if possible, give me a sample code.Saturday, September 8, 2007 5:50 PM
-
well luckily i do have a sample code for u sanket:
Dim fs As FileStream
Dim fileContents As Byte()
fs = New FileStream(OpenFileDialog.FileName,
FileMode.Open, FileAccess.Read, FileShare.Read, _
4096, True)
ReDim fileContents(fs.Length)
fs.BeginRead(fileContents, 0, fs.Length, callback, Nothing)Saturday, September 8, 2007 6:07 PM -
Hey its nice response.
But what "4096" is doing here ?Saturday, September 8, 2007 6:09 PM -
hi i think so through port number u can get the ip address of the current system....Monday, September 10, 2007 10:51 AM
-
Check this code for getting IP address
Imports System.Net
Public Class CGetLocalIPAddress
Dim sIpAddr As String
'Dim myLocalIP As New CGetLocalIPAddress
Public Sub New()
GetLocalIPAddress()
End Sub
Private Sub GetLocalIPAddress()
Dim ipEntry As IPHostEntry = Dns.GetHostByName(Environment.MachineName)
Dim mIpAddr As IPAddress() = ipEntry.AddressList
Dim i As Integer
sIpAddr = mIpAddr(1).ToString()
End Sub
Public Property LocalIPAddress() As String
Get
Return sIpAddr
End Get
Set(ByVal Value As String)
sIpAddr = Value
End Set
End Property
End ClassMonday, September 10, 2007 7:48 PM -
it must b in sys registry check it now!Tuesday, September 11, 2007 12:06 PM
-
hi swati,
have u knowledge abt make telephony call using regular or any modem coding in VB.net? If u know abt that then plz put that code here or u can send that file on kapilshukla2006@hotmail.com.
Wednesday, November 28, 2007 9:16 AM -
thnx mam
i badly needed this code.
Tuesday, December 4, 2007 4:12 AM -
Dim hostname As IPHostEntry = Dns.GetHostByName(hostname)
Dim ip As IPAddress() = hostname.AddressListhttp://vb.net-informations.com/communications/vb.net_find_ip_address.htm
http://vb.net-informations.com/communications/vb.net_communications_tutorial.htm
hope this will help
Friday, April 25, 2008 8:41 AM