Jump to content
Xtreme .Net Talk

Phreak

Avatar/Signature
  • Posts

    63
  • Joined

  • Last visited

Everything posted by Phreak

  1. Thanks! TimeSpan worked exactly how I wanted. I really appreciate the help!
  2. Ok, I found the DateDiff function, but it keeps returning the value '0'. Here is what I have: tTTime = DateDiff(DateInterval.Hour, CType(tSTime, Date), CType(tETime, Date)) I did a debug and checked out the values of the variables when it gets to this line and the values are: tSTime = 14:25:45 tETime = 14:27:40 So there is a difference. Can anyone please help? I am suppose to have this figured out by the end of the day tomorrow.
  3. This is kind of weird, so hopefully someone can answer this. I'm populating a listview control from multiple text files, however, I'm getting an error: " An unhandled exception of type 'System.InvalidOperationException' occurred in system.windows.forms.dll Additional information: This collection has reached its maximum capacity. " Here is my code: If iNotFound = 1 Then sTmpUserNms.Add(iNmCnt, aLocVals(1)) Dim Item1 As New Windows.Forms.ListViewItem.ListViewSubItem(iTmp, sTmpUserNms(iNmCnt).ToString) 'iTmp.Text = aValues(0) iTmp.SubItems.Add(Item1) 'iTmp.SubItems.Add(Item2) 'lstData.Items.Add(iTmp) iNmCnt += 1 End If I get the error at "iTmp.SubItems.Add(Item1)". I get it when it is trying to add the 4096 item. And I only get it when I have "lstData.Items.Add(iTmp)" commented out. However, when I uncomment that, I get the error:" An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll Additional information: Cannot add or insert the item '' in more than one place. You must first remove it from its current location or clone it. " Please help!
  4. What I'm trying to do is sort through an IIS log file, and add up the total time a user has spent on the site. Each log file is separated by days, and everytime a user opens a new page, the time is logged. So I can have multiple records for the same user with different times. Say for instance they opened "this" page at 10:30:15, and then opened another page at 10:31:25, and another at 10:33:40. How can I add all of these times together to get the TOTAL time a user spent on the site? For instance, the total time the user used in the above example spent 3 min 25 sec on the site. Is there a way to do that? Maybe even easier, put in the 1st time and the last time logged and have it spit out the whole time span?
  5. I found this Javascript function and it seems to be working. If anybody finds any flaws in it, PLEASE let me know. I can't seem to find any. <html> <head><!-- Do not cache this page --> <meta http-equiv="Pragma" content="no-cache"> <title>Speed Test - Graphics</title> </head> <!-- This function computes the time it took to load up the page --> <script language="JavaScript"> function results() { var time2, timed, thruput, title time2 = new Date() //Calc difference and convert from msec to sec. timed = (time2.getTime()-time1.getTime()) / 1000 /* Calc Kbps using formula: [throughput (in Kbps)] = [file size (in bytes)] * 8 / [elapsed time] / 1000 */ thruput = (225455 * 8) / timed / 1000 document.open() // Stops the page from loading. document.close() // Turns off the hourglass. title = "Speed Test - Graphics" document.write("<html><meta http-equiv='Pragma' content='no-cache'><title>" + title + "</title>") document.write("<body bgcolor='#FFFFFF'>") document.write("<h1 align='center'>" + title + "</h1>") document.write("<font size='4'><center>Loaded 225,455 bytes in " + (timed) + " seconds.</center>") document.write("<center>Your throughput is <B>" + Math.round(thruput) + "</B> Kbps.</center></font>") document.write("<hr noshade>") document.write("<p align='center'><a href='" + document.location + "'>Run Test Again</a></p>") document.write("</html>") } </script> <body onload="results()" bgcolor="#FFFFFF"> <!-- Start timer --> <script language="JavaScript"> time1 = new Date() </script> <p align="center"><big><font face="Verdana, Arial, Helvetica, sans-serif" size="2"><b>Speed Test - Graphics</b></font></big></p> <p align="center"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Loading 225,455 bytes (compressed JPEG)... please wait.</font></b></p> <hr noshade> <font face="Arial, Helvetica, sans-serif"> <!-- defeat the browsers image cache by appending a timestamp --> <script language="JavaScript"> imgLocation = "images/test.jpg" + "?" + time1.getTime() document.write("<p align='center'><img src='" + imgLocation + "' align='center' width='256' height='256' alt='Loading 225,455 bytes...'></p>") </script> </font> <hr noshade> </body> </html>
  6. Anyone have any idea how you could detect the connection speed of someone viewing your website? AND calculate the estimated time for a download of a certain file. I thought about trying to ping the ip of the connection and do some math, but that's not a correct way to configure bandwidth. Anyone have any ideas about how to accomplish this?
  7. What kind of configuration information? I'm not really sure what you mean. But I think you might be able to get by with a text file or something that the service can read. I'm pretty sure you can't actually "interact" with the service except for starting, stopping, pausing, etc. the service. Or create a "client" program that communicates with the service through sockets.
  8. Well, the TcpClient object that is returned is passed to a Client object from my Client class. Dim x As New Client(mobjListener.AcceptTcpClient) So I made the Client class inherit from TcpClient, and when my Disconnected event was raised (I raised it), the client object is passed to it, and I call the Close method, however it doesn't disconnect. Here is that code: Private Sub OnDisconnected(ByVal sender As Client) sender.Close() UpdateStatus("Disconnected") mcolClients.Remove(sender.ID) End Sub Any other ideas? Anyone?
  9. Now you lost me, call the Close method of the TCPClient on the server application that is created by the TCPListner.AcceptClient? Pardon my asking how I would do that? Or do you know of somewhere that goes over this topic?
  10. Is it possible, if I have a TCPListener running, and it has multiple connections to it; to force disconnect one of the connections? Example: Billy, Jimmy, and Tommy all just connected to it (in that order), and Billy didn't supply the correct syntax for logging on (potential hacker); is there a way to have the TCPListner or something, disconnect that specific connection?
  11. That worked great... thanks!
  12. Ok, this is REALLY starting to frustrate me. I have a collection list that contains all 237 countries starting at 0 through 236. I also have a For loopthat fills a combo box with this collection list. Now, all of this is done on the form load event, and I want the default selected start item to be the United States, which has an index of 222 in the combox (after it's filled) and 223 in the collection list. Here is the code (without the list of countries): For i = 1 To cCountries.Count Step 1 cmbCountry.Items.Add(cCountries.Item(i)) Next cmbCountry.SelectionStart = 222 No matter what I do, the drop down combo box never has a default item selected, it's always blank. Any ideas what I'm doing wrong?
  13. Hey thanks! That'll do just fine. :D
  14. Option strict basically disallows any implicit conversions of data types. The reason for this, is that somewhere down the line (usually after you've already deployed the application), converting one type to another type might cause undesired results and hence, crashing your application. So with Option Strict On, you are not allowed to build your solution/project if you have implicit conversions. Try using CType(STRING, INT) or vice-versa, so you aren't implicitly converting data types.
  15. I'd like to allow a user to select their country and state (if from US) from a drop down list. Does anyone know where I can get a list of all the countries so I don't have to manually type in all 200 and some? I've searched all over and can't seem to find a list of countries... any help?
  16. Phreak

    Handshaking

    So you mean if a user doesn't have that password, the server will disconnect them. Because what I don't want, is someone just connecting to the server using TCP and gaining access to the server itself. That's what I'm trying to prevent. Because people are going to be connected to the server when they're not chatting with anyone, but they should only be connected through our program. I want to prevent anyone from connecting that is not using our program.
  17. Nevermind I got it... man I'm just not thinking at all today... must need more sleep... :) I put "Dim Client As PB.Comm" in the global decs area, and put Client = New PB.Comm in the OnLoad event.
  18. Well, my Client object isn't accessable in my other routines if I declare it in the OnLoad event, should I declare it globally? Would that work then? Would I just move the Dim Client As PB.Client = New PB.Client line to the global dec area?
  19. Great! I think that worked... so I just need to use the Client.CurrentClient each time basically to access "TcpClient" object?
  20. Hmmm.... ok, maybe I'm not getting it or I didn't explain it very well. Here is my entire Comm class so far: Option Explicit On Option Strict On Imports System.Net.Sockets Imports System.Text Public Class Comm Public Sub New() MyBase.New() End Sub #Region "Global Declarations" Const PORT_NUM As Int16 = 5000 Const READ_BUFFER_SIZE As Integer = 255 Private objClient As TcpClient Public Delegate Sub DisplayInvoker(ByVal t As String) #End Region Private Sub CreateTCPClient() objClient = New TcpClient("localhost", PORT_NUM) End Sub ' Use a StreamWriter to send a message to server. Private Sub SendData(ByVal data As String) Dim writer As New IO.StreamWriter(objClient.GetStream) writer.Write(data & vbCr) writer.Flush() End Sub Public ReadOnly Property CurrentClient() As TcpClient Get 'check if you got a instance of one, and create if neccessary If objClient Is Nothing Then CreateTCPClient() End If Return objClient End Get End Property End Class Now that's in the Comm.vb file in the PB class library. Here is the OnLoad method in the frmCChat.vb file in my Chat windows application. Private Sub frmCMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try objClient = Client.CurrentClient() ' Start an asynchronous read invoking DoRead to avoid lagging the user interface. objClient.GetStream.BeginRead(readBuffer, 0, READ_BUFFER_SIZE, AddressOf DoRead, Nothing) ' Make sure the window is showing before popping up connection dialog. Me.Show() DisplayText("Connected to host" & vbCrLf) 'AttemptLogin() Catch Ex As Exception MsgBox("Could not connect to server. Please try again later.", _ MsgBoxStyle.Exclamation, Me.Text) Me.Dispose() End Try End Sub Is the objClient = Client.CurrentClient line correct? (I already created the object Client in the global declarations). If it is correct, why is objClient not a TcpClient object? Such as the next line below it is not correct.
  21. Ok. How do I use an object created in a DLL in my form. For instance, I have Class Library named PB and a class named Comm. Now, I have a sub that creates a TCPClient in my Comm class. In my form class I create a new object of Comm. And run the method to create the TCPClient. How do I reference that in my form? Here is my class code: ' -------------------------------------------------------------------------------------- ' START GLOBAL DECLARATIONS ' -------------------------------------------------------------------------------------- Const PORT_NUM As Int16 = 5000 Const READ_BUFFER_SIZE As Integer = 255 Public objClient As TcpClient Public Delegate Sub DisplayInvoker(ByVal t As String) ' -------------------------------------------------------------------------------------- ' END GLOBAL DECLARATIONS ' -------------------------------------------------------------------------------------- Public Sub CreateTCPClient() objClient = New TcpClient("localhost", PORT_NUM) End Sub ' Use a StreamWriter to send a message to server. Private Sub SendData(ByVal data As String) Dim writer As New IO.StreamWriter(objClient.GetStream) writer.Write(data & vbCr) writer.Flush() End Sub End Class In my form code I dimension and create a new PB.Comm object named Client. I then run the method CreateTCPClient in the OnLoad routine. Any help on using that newly created objClient object in my form code? Or am I going about this the wrong way?
  22. Phreak

    Handshaking

    I was thinking more along the lines of a hacker connecting to that port on the server. Or is that what you mean?
  23. Ok... as I've mentioned before in some other threads, a friend of mine and I are trying to create a messaging program completely from scratch. Now, with the suggestions of others, we've decided on using the client/server method as opposed to peer-to-peer. Now, for my question. We don't just want "anyone" connecting to this port on our server, so we want to develop some type of "handshake". How would one go about setting up a connection so that in order to connect to the server, the client must provide a "connect string" to authenticate the client or the connection is dropped by the server. Such as: If someone doesn't provide the required information within a certain time period when connected to that port, the server drops the connection. Thanks.
  24. Try puting the login information in the connection string for your connection object.
  25. Okay, I did a search for this, but had no luck whatsoever, so I'm just going to ask. I want to have some sort of list (probably a listview control), to contain a list of "contacts", next to each contact I would like an image. Is there a way to do this with ListView or do I need to look towards a different control. Example of what I'm looking for would be the "Buddy List" in either AIM or MSN Messenger. Thanks!
×
×
  • Create New...